Shared Data Edits between Tables with Different Filters?

Tags: #<Tag:0x00007efc64d3d5a8> #<Tag:0x00007efc64d3d378>

Hello,

I am looking to have multiple Handsontable objects share data, but have different filters.

Is it true that if I pass in a single dataset to multiple Handsontables, like so, that they will all update these tables and synchronize, even if filtered differently?

// Shared data for all Handsontable instances
const sharedData = [
  // ... your data rows here ...
];

// Function to create a new Handsontable instance with shared data but independent filters
function createHandsontableInstance(container, filtersConfig) {
  // Initialize Handsontable instance
  const hotInstance = new Handsontable(container, {
    data: sharedData,
    // ... other shared configuration options ...
    filters: true,
    // other options specific to this instance...
  });

  // Apply instance-specific filters if provided
  if (filtersConfig) {
    hotInstance.addHook('afterLoadData', () => applyFilters(hotInstance, filtersConfig));
  }

  return hotInstance;
}

// Function to apply filters to a Handsontable instance
function applyFilters(hotInstance, filtersConfig) {
  // logic to apply filters based on filtersConfig to hotInstance
}

// Creating multiple instances with the same shared data but different filters
const hot1 = createHandsontableInstance(document.getElementById('hot1'), filtersConfig1);
const hot2 = createHandsontableInstance(document.getElementById('hot2'), filtersConfig2);

// Now, hot1 and hot2 share the same data array but have independent filter configurations.

Hi @ken

Thank you for contacting us. This is an interesting case, so I checked it in a simple scenario with three instances and one, shared dataset: https://jsfiddle.net/handsoncode/cLyrw06s/

When I applied the filters in one of the instances the other remained in their default state, so, as long as you create an independent instance for Handsontable to which you apply different filters config, even with the shared data filtering should work independently.