Search code examples
jqgridjquery

Attach method to all jqgrid instances?


I want to remove the pointer cursor from all non-sortable column headers in all of my jqGrids as in this answer. I currently do so for some of them in the gridComplete event.

Is there a way to set a default event, or grab all of the jqGrids on a page, and append that function the gridComplete event? I could not find anything in the options.


Solution

  • If you don't change the value of sortable property of the columns dynamically you don't need to do this on every grid refreshing. The columns will be created once at the creating of jqGrid. So you can just place the code which fixes the cursor on non-sortable columns after the grid definition. So you don't need to use gridComplete or any other callback.

    By the way I use the word "callback" instead of "event" used in jqGrid documentation because you can define really one callback per grid. So you can't easy define somewhere in common place gridComplete with common actions and use another gridComplete in the grid definition. So if you define gridComplete as default option $.jgrid.defaults (see here) it will default till you not overwrite it in the definition of some jqGrid. To fix the problem I posted detailed suggestion how to extend functionality of jqGrid to support real events. Later I posted pull request with the changes. After long discussion the functionality is included in the code of jqGrid. So the next version jqGrid (which should be published in a short time) will do have support events additionally to callbacks.