jqGrid细节备注—jqGrid有很多事件

简介:
jqGrid有很多事件,包括事件的参数,在下表中列出。
常用的事件包括afterInsertRow ,gridComplete,loadComplete,onCellSelect,onRightClickRow,onSelectRow等
代码示例如下:
jQuery("#gridid").jqGrid({
...
  onSelectRow:function(rowid,stat)
  {
  alert(rowid);
  alert(stat)
  },
...
});

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

beforeProcessing

data, status, xhr

This event fire before proccesing the data from the server. Note that the data is formatted depended on the value of the datatype parameter - i.e if the datatype is 'json' for example thedata is JavaScript object

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 not made to the server

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.

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, 
settings

A pre-callback to modify the XMLHttpRequest object (xhr) before it is sent. Use this to set custom headers etc. Returning false will cancel the request.

loadComplete

data

This event is executed immediately after every server request.  
data Data from the response depending on datatype grid parameter

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 (status) that occurred and an optional exception object (error), if one occurred.

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).

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

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

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 paging

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

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.

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.

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

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.  
To this event we pass the postData array.

调用ajax的事件顺序如下:

1.beforeRequest

2.loadBeforeSend

3.serializeGridData

4.loadError (if a error from the request occur - the event from steps 5 till 7 do not execute. If there is no error the event 4. does not execute and we continue to with the step 5.)

5.beforeProcessing

6.gridComplete

7.loadComplete
















本文转自cnn23711151CTO博客,原文链接:http://blog.51cto.com/cnn237111/782124 ,如需转载请自行联系原作者


相关文章
|
6月前
05jqGrid - 事件
05jqGrid - 事件
20 0
|
6月前
|
JavaScript
Layui 弹层组件 - 基础参数3
Layui 弹层组件 - 基础参数3
35 0
|
6月前
|
JavaScript 前端开发
Layui 弹层组件 - 基础参数1
Layui 弹层组件 - 基础参数1
45 0
|
4月前
|
JavaScript
原生JS修改html内容不影响绑定的点击事件 请认准insertAdjacentHTML、insertAdjacentText方法
原生JS修改html内容不影响绑定的点击事件 请认准insertAdjacentHTML、insertAdjacentText方法
原生JS修改html内容不影响绑定的点击事件 请认准insertAdjacentHTML、insertAdjacentText方法
|
6月前
Layui 弹层组件 - 基础参数2
Layui 弹层组件 - 基础参数2
22 0
|
6月前
|
JavaScript
Layui 弹层组件 - 基础参数4
Layui 弹层组件 - 基础参数4
28 0
|
6月前
|
JavaScript 索引
Layui 弹层组件 - 基础参数5
Layui 弹层组件 - 基础参数5
29 0
|
8月前
|
JavaScript
原生js生成唯一id方法
原生js生成唯一id方法
76 0
|
API
对dwz的combox组件扩展属性
对dwz的combox组件扩展属性
97 0
|
前端开发 JavaScript
dwz中jqGrid的主题变更
dwz中jqGrid的主题变更
85 0
dwz中jqGrid的主题变更