6pac / SlickGrid

A lightning fast JavaScript grid/spreadsheet
https://github.com/6pac/SlickGrid/wiki
MIT License
1.82k stars 424 forks source link

Ability to catch and resend DOM messages which are grid scoped. #1021

Closed b-giavotto closed 3 months ago

b-giavotto commented 3 months ago

Clear and concise description of the problem

Is there a way to handle all slickgrid messages in a centralized way by catching and killing them, and upon a specific event (a async callback or a specified interval of time for example) resend them ?

Basically i need to capture a specific event, saving all event informations, then issue an async call to a server method, and after got the response re-create the same DOM or slickgrid event and send it to the grid as if it was the original one.

Suggested solution

What i've asked

Alternative

No response

Additional context

No response

Validations

6pac commented 3 months ago

You can use the SlickGrid trigger method to trigger SlickGrid events manually. The return code of some events can be used to cancel the entire action, other events don't have this ability. DOM events can usually be cancelled with event.preventDefault or similar, and can be called manually. With both SlickGrid and DOM events, you'd have to save the event values somewhere for later re-use.

6pac commented 3 months ago

Noticed you posted on StackOverflow too. I don't think there will be a generalised solution for all events because there would be some severe side effect from some events, eg mouse movements and scrolling, being piped through a round trip to a server. Also if an event is called multiple times you'd possibly need a queue structure for the parameters. It's a lot of extra complexity.
So as I said, you'd want to target specific events, although you could write one sgement of generalised code to reroute those events. We can add cancelability to some SlickGrid actions if that would help.

b-giavotto commented 3 months ago

Noticed you posted on StackOverflow too. I don't think there will be a generalised solution for all events because there would be some severe side effect from some events, eg mouse movements and scrolling, being piped through a round trip to a server. Also if an event is called multiple times you'd possibly need a queue structure for the parameters. It's a lot of extra complexity. So as I said, you'd want to target specific events, although you could write one sgement of generalised code to reroute those events. We can add cancelability to some SlickGrid actions if that would help.

I'm aware of the issues you highlighted above. However, i just asked if does exists, in slickgrid a centralized point when one could handle slickgrid events. Improper usage of those events and side effects, is of course up to me.

In the past i've done something similar to browser dom events applyed to single DOM nodes, and worked fine. However, because slickgrid is more complex than a simple dom node i hoped for a more centralized way to catch events. this would be beneficial because it allowed a more abstract, (at higher level), grid oriented way to do this. Never checked the source code, but maybe there is a place where the grid handle DOM crude events to higher abstract event (such for example validated event which does not have a direct counterpart on DOM)

ghiscoding commented 3 months ago

This is a question, not an issue, so I'm moving this to a Discussion