tonytomov/jqGrid — Issue #197: jQuery events for flexibility
Author: marcofranssen
Created: 2011-11-15 14:48:48+00:00
State: open

jqgrid should use jquery events to allow much more easy working with jqgrid!

Now you can only implement for example the onGridComplete. This overrides the default functionality.

However in advanced scenario's you would like to do stuff like this.

```javascript
jqGrid.bind('gridCompleted', function(event, data) {
//Do stuff when grid has completed everytime
});
jqGrid.one('gridCompleted', function(event, data) {
//Do stuff when grid has completed only once
});

jqGrid.bind('rowExpanded', function(event, data) {
//Do stuff when a row is expanded
});
jqGrid.one('rowExpanded', function(event, data) {
//Do stuff when a row is expanded the first time
});

jqGrid.bind('filtered', function(event, data) {
//Do stuff when a row is filtered
});
jqGrid.one('filtered', function(event, data) {
//Do stuff when a row is filtered the first time
});
```
It would be really easy for you guys to support the current way of working with jqgrid and the one I suggesting here.
I think you only need to call following code in the right places. In the longer term I think the overriding of the gridComplete functions etc. should become deprecated.

```javascript
$(this).trigger('gridCompleted', eventdata);
$(this).trigger('rowExpanded', eventdata);
$(this).trigger('rowCollapsed', eventdata);
$(this).trigger('rowAdded', eventdata);
$(this).trigger('filtered', eventdata);
//etc.
//etc.
//etc.

//NOTE: eventdata above is for example an object which contains the rowId in the rowExpanded and rowCollapsed events
```
For every thing that happens and you possibly would like to do some manipulations after it happened should have this kind of events.

jqGrid users can bind to these events when they need it.

For now I do the same just by writing a wrapper arround it for my specific scenario's where I really need it. In my case only the gridComplete for now on one of my specific grids.

The guy who adds this will add a huge value (flexibility, scalability) to jqgrid without doing big loads of work. Not have the time to do this myself because of deadlines in my project.