<?php ... // Create the jqGridEdit instance $grid = new jqGridRender($conn); // Write the SQL Query $grid->SelectCommand = 'SELECT OrderID, OrderDate, CustomerID, Freight, ShipName FROM orders'; $grid->dataType = "json"; $myevent = <<<ONSELECT function(rowid, selected) { if (rowid) alert("Row is selected"); } ONSELECT; $grid->setGridEvent('onSelectRow',$myevent); .... $grid->renderGrid(); ?>
As can be seen from this example the first parameter of the method is the name of the event and the second is the code associated with that event. Note how $myevent is written - function(params,...) - This will produce in the cleint
onSelectRow:function(rowid, selected) {....}
Below is the list of events that can be used into the grid:
Event |
Parameters |
Description |
---|---|---|
afterInsertRow |
rowid |
This event fires after every inserted row. |
beforeRequest |
none |
This event fire before requesting any data. Also does not fire if datatype is function. If the event return false the request is canceled and not send to the server. |
beforeProcessing |
data - the data from the response, st - status of the request |
This event fire immediatley after the successed ajax request and before executing the adding new data |
beforeSelectRow |
rowid, e |
This event fire when the user click on the row, but
before select them. |
gridComplete |
none |
This 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. |
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 |
xhr |
This event is executed immediately after every
server request. |
loadError |
xhr, |
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. |
onCellSelect |
rowid, |
Fires when we click on particular cell in the grid. |
onClickGroup |
groupid, |
This event fires after clicking group (to expand or collapse group). it has 2 parameters, group id (string) and collapsed (boolean). 'groupid' is a combination of grid id plus 'ghead_' plus the current count number in the grid view. . 'collapsed' is current group's collapse status. |
ondblClickRow |
rowid, |
Raised immediately after row was double clicked. |
onHeaderClick |
gridstate |
Fire after clicking to hide or show grid
(hidegrid:true); |
onPaging |
pgButton |
This 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.
|
onRightClickRow |
rowid, |
Raised immediately after row was right clicked. |
onSelectAll |
aRowids, |
This event fires when multiselect option is true and
you click on the header checkbox. |
onSelectRow |
rowid, |
Raised immediately after row was clicked. |
onSortCol |
index, |
Raised immediately after sortable column was clicked
and before sorting the data. |
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. |
serializeGridData |
postData |
If 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. |