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.