svelte-ag-grid icon indicating copy to clipboard operation
svelte-ag-grid copied to clipboard

Do not override user defined event functions

Open roydukkey opened this issue 3 years ago • 1 comments

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,
	});
});

roydukkey avatar Dec 14 '20 21:12 roydukkey