Export page to Open Document format

Events

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

See also jqGrid Methods.

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

The above example specifies the action to take when a row is selected. The events that you can use to perform some additional action are listed here, in alphabetic order:

As of version 3.6.3 to every event is passed the reference (this) to the grid. This means that inside every event you can use $(this) which refers to the grid. Using the above example both are equivalent

var lastSel;
jQuery("#gridid").jqGrid({
...
   onSelectRow: function(id){ 
      if(id && id!==lastSel){ 
         jQuery(this).restoreRow(lastSel); 
         lastSel=id; 
      } 
      jQuery(this).editRow(id, true); 
   },
...
});

List of Events

EventParametersDescription
afterInsertRowrowid
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
Note: this event does not fire if gridview option is set to true
beforeRequestnone This event fire before requesting any data. Also does not fire if datatype is function
beforeSelectRowrowid, e This event fire when the user click on the row, but before select them.
rowid is the id of the row.
e is the event object
This event should return boolean true or false. If the event return true the selection is done. If the event return false the row is not selected and any other action if defined does not occur.
gridCompletenoneThis fires after all the data is loaded into the grid and all other processes are complete. Also the event fires independent from the datatype parameter and after sorting paging and etc.
loadBeforeSendxhrA 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.
loadCompletedataThis event is executed immediately after every server request.
data Data from the response depending on datatype grid parameter
loadErrorxhr,
status,
error
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 (satus) that occurred and an optional exception object (error), if one occurred.
onCellSelectrowid,
iCol,
cellcontent,
e
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,
e is the event object element where we click.
(Note that this available when we not use cell editing module and is disabled when using cell editing).
ondblClickRowrowid,
iRow,
iCol,
e
Raised immediately after row was double clicked.
rowid is the id of the row,
iRow is the index of the row (do not mix this with the rowid),
iCol is the index of the cell.
e is the event object
onHeaderClickgridstateFire after clicking to hide or show grid (hidegrid:true);
gridstate is the state of the grid - can have two values - visible or hidden
onPagingpgButtonThis event fires after click on [page button] and before populating the data. Also works when the user enters a new page number in the page input box (and presses [Enter]) and when the number of requested records is changed via the select box. To this event we pass only one parameter pgButton See pager.
If this event return 'stop' the processing is stopped and you can define your own custom paging
onRightClickRowrowid,
iRow,
iCol,
e
Raised immediately after row was right clicked.
rowid is the id of the row,
iRow is the index of the row (do not mix this with the rowid),
iCol is the index of the cell.
e is the event object.
Note - this event does not work in Opera browsers, since Opera does not support oncontextmenu event
onSelectAllaRowids,
status
This event fires when multiselect option is true and you click on the header checkbox.
aRowids array of the selected rows (rowid's).
status - boolean variable determining the status of the header check box - true if checked, false if not checked.
Note that the aRowids alway contain the ids when header checkbox is checked or unchecked.
onSelectRow rowid,
status
Raised immediately after row was clicked.
rowid is the id of the row,
status is the status of the selection. Can be used when multiselect is set to true. true if the row is selected, false if the row is deselected.
onSortColindex,
iCol,
sortorder
Raised immediately after sortable column was clicked and before sorting the data.
index is the index name from colModel,
iCol is the index of column,
sortorder is the new sorting order - can be 'asc' or 'desc'.
If this event return 'stop' the sort processing is stopped and you can define your own custom sorting
resizeStart event, index Event which is called when we start resize a column. event is the event object, index is the index of the column in colModel.
resizeStop newwidth, index Event which is called after the column is resized. newwidth is the is the new width of the column , index is the index of the column in colModel.
serializeGridDatapostDataIf set this event can serialize the data passed to the ajax request. The function should return the serialized data. This event can be used when a custom data should be passed to the server - e.g - JSON string, XML string and etc.
To this event we pass the postData array.

Additional Events specific to Cell Editing, subGrid are found in their respective topics.

Execution Order

Below is the execution order of the events when a ajax request is made

  1. beforeRequest
  2. loadBeforeSend
  3. serializeGridData
  4. loadError (if a error from the request occur - the event 5 and 6 do not execute. If there is no error the event 4. does not execute and we continue to with 5. and 6.)
  5. gridComplete
  6. loadComplete

Personal Tools
;
;