Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Do not override user defined event functions #9

Open
roydukkey opened this issue Dec 14, 2020 · 1 comment
Open

Do not override user defined event functions #9

roydukkey opened this issue Dec 14, 2020 · 1 comment

Comments

@roydukkey
Copy link
Contributor

It is not currently possible for the consumer to define their own onGridReady, onCellValueChanged, onSelectionChanged since they are override by the onMount functionality.

onMount(() => {
grid = new Grid(ref, {
...options,
columnDefs,
rowData: data,
onGridReady,
onCellValueChanged,
onSelectionChanged,
});
});

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
Copy link
Contributor Author

roydukkey commented Dec 15, 2020

Here's a working branch for this: master...roydukkey:issue/9.

I know this adds more complexity to the wrapper, which is intended to be lightweight, so if this is undesired, I'll keep this on my fork otherwise, I'll submit a PR.

Also, note that I have changed how the api field is recorded. Accessing the event rather than the grid's grid options should be slightly quicker.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant