Events

The action to take on an event is set as a property of the grid, e.g.

onSelectRow: function(id){ if(id && id!==lastSel){ jQuery('#tbleditable').restoreRow(lastSel); lastSel=id; } jQuery('#tbleditable').editRow(id, true); },

The above example specifies the action to take when a row is selected. The following one shows how to use onSortCol:

onSortCol: function( index, colindex, sortorder) { // here is the code }

The events that you can use to perform some additional action are listed here, in alphabetic order:

Event Parameters Description
afterInsertRow rowid, rowdata, rowelem This event fires after every inserted row.
  • rowid is the id of the inserted row
  • rowdata is an array of the data to be inserted into the row. This is array of type name: value, where the name is a name from colModel
  • rowelem is the element from the response. If the data is xml this is the xml element of the row; if the data is json this is array containing all the data for the row
gridComplete none This fires after all the data is loaded into the grid and all other processes are complete
loadBeforeSend xhr A pre-callback to modify the XMLHttpRequest object (xhr) before it is sent. Use this to set custom headers etc. The XMLHttpRequest is passed as the only argument.
loadComplete none This event is executed immediately after every server request
loadError xhr,st,err A function to be called if the request fails. The function gets passed three arguments: The XMLHttpRequest object (XHR), a string describing the type of error (st) that occurred and an optional exception object (err), if one occurred.
onCellSelect rowid, iCol, cellcontent fires when we click on particular cell in the grid rowid is the id of the row iCol is the index of the cell cellcontent is the content of the cell. (Note that this available when we not use cell editing module and is disabled when using cell editing). Important note regarding IE6: this event may exhibit strange behaviours because of a bug in early IE6 releases. When we have a hidden column the index will not be calculated correctly. You can avoid using this feature in a grid with hidden columns, test for these browsers and conditionally suppress this feature, or suggest that your IE6 users upgrade. For more information refer to http://support.microsoft.com/kb/814506
ondblClickRow rowid Raised immediately after row was double clicked.
Calling convention:
ondblClickRow: function( rowid) {
    // here is the code
  }
onHeaderClick gridstate Can be used when clicking to hide or show grid; gridstate is the state of the grid (visible or hidden)
onRightClickRow rowid Raised immediately after row was right clicked.
onSelectAll array of the selected ids This event fires (if defined) when multiselect is true and you click on the header checkbox. Parameter passed to this event is array of selected rows. If the rows are unselected, the array is empty.
onSelectRow rowid Raised immediately after row was clicked.
onSortCol index, colindex, sortorder Raised immediately after sortable column was clicked and before sorting the data
  • index is the index name from colModel
  • colindex is the index of column
  • sortorder is the sorting order - can be 'asc' or 'desc'


Additional Events specific to Cell Editing, subGrids and Tree Grids are found in their respective topics.



  Last Updated: 2/15/2009 | © Tony's jqGrid - a jQuery Plugin, 2010