jqGrid基础学习:5jqGrid中事件的使用

jqGrid中提供了丰富的事件。主要如下,这些只要看看就好。部分用不到,部分要到再详解。

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
Note: this event does not fire if gridview option is set to true当插入每行时触发。rowid插入当前行的id;rowdata插入行的数据,格式为name: value,name为colModel中的名字。rowelem是从服务器返回的数据,如果数据时xml则返回该行的xml数据,如果是json,就返回这行关于这行的所有数据的数组。
beforeRequest none This event fire before requesting any data. Also does not fire if datatype is function向服务器端发起请求之前触发此事件但如果datatype是一个function时例外
beforeSelectRow rowid, 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.当用户点击当前行在未选择此行时触发。rowid:此行id;e:事件对象。返回值为ture或者false。如果返回true则选择完成,如果返回false则不会选择此行也不会触发其他事件
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.在发送之前设置一个预先的回调函数来改变xhr对象,使用该方法可以社智能光自定义headers。xhr对象做为一个参数来传递
loadComplete xhr This event is executed immediately after every server request.
xhr XMLHttpRequest object当从服务器返回响应时执行,xhr:XMLHttpRequest 对象
loadError xhr,
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.如果请求服务器失败则调用此方法。xhr:XMLHttpRequest 对象;satus:错误类型,字符串类型;error:exception对象
onCellSelect rowid,
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).当点击单元格时触发。rowid:当前行id;iCol:当前单元格索引;cellContent:当前单元格内容;e:event对象
ondblClickRow rowid,
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双击行时触发。rowid:当前行id;iRow:当前行索引位置;iCol:当前单元格位置索引;e:event对象
onHeaderClick gridstate Fire after clicking to hide or show grid (hidegrid:true);
gridstate is the state of the grid – can have two values – visible or hidden当点击显示/隐藏表格的那个按钮时触发;gridstate:表格状态,可选值:visible or hidden
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.
If this event return ‘stop’ the processing is stopped and you can define your own custom pagging点击翻页按钮填充数据之前触发此事件,同样当输入页码跳转页面时也会触发此事件
onRightClickRow rowid,
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在行上右击鼠标时触发此事件。rowid:当前行id;iRow:当前行位置索引;iCol:当前单元格位置索引;e:event对象。此事件不支持opera游览器
onSelectAll aRowids,
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.multiselect为ture,且点击头部的checkbox时才会触发此事件。aRowids:所有选中行的id集合,为一个数组。status:boolean变量说明checkbox的选择状态,true选中false不选中。无论checkbox是否选择,aRowids始终有值
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.选择行时触发此事件。rowid:当前行id;status:选择状态,当multiselect 为true时此参数才可用
onSortCol index,
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当点击排序列但是数据还未进行变化时触发此事件。index:name在colModel中位置索引;iCol:当前单元格位置索引;sortorder:排序状态:desc或者asc
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.当开始改变一个列宽度时触发此事件。event:event对象;index:当前列在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.当列宽度改变之后触发此事件。newwidth:列改变后的宽度;index:当前列在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.
To this event we pass the postData array.向服务器发起请求时会把数据进行序列化,用户自定义数据也可以被提交到服务器端

你可能感兴趣的:(object,function,服务器,XMLhttpREquest,processing,sorting)