svelte-ag-grid
svelte-ag-grid copied to clipboard
Do not override user defined event functions
It is not currently possible for the consumer to define their own onGridReady
, onCellValueChanged
, onSelectionChanged
since they are override by the onMount
functionality.
https://github.com/Budibase/svelte-ag-grid/blob/9d19c4c991ed9034510cc3754a551029a8c3d691/src/Component.svelte#L49-L58
I think it would be find to assume that over event's should fire before any user defined events, so I would propose this solution, implement similarly for all three events.
let consumerOnGridReady;
const onGridReady = (params) => {
api = grid.gridOptions.api;
if (loading) api.showLoadingOverlay();
if (consumerOnGridReady) consumerOnGridReady(params);
};
onMount(() => {
if (options.onGridReady) {
consumerOnGridReady = options.onGridReady;
}
grid = new Grid(ref, {
...options,
columnDefs,
rowData: data,
onGridReady,
onCellValueChanged,
onSelectionChanged,
});
});