Reproduced
1, property
parameter name | Types of | description | Defaults | It can be modified |
ajaxGridOptions | object | Ajax parameters to be set globally, can cover the event ajax: error, complete and beforeSend | Null | Yes |
ajaxGridOptions | object | Ajax parameters to be set globally | Null | Yes |
ajaxSelectOptions | object | select property values of select parameters were ajax global settings, parameter settings editoptions with searchoptions | Null | Yes |
altclass | String | Line alternating color table for class attribute. You can define your own class instead of the default. Only when the set altRows property is true, the property has an effect | ui-priority-secondary | Yes, but you need to reload |
altRows | boolean | Table rows are alternately arranged whether to allow color value | false | Is the need to reload |
autoencode | boolean | When ture for url to be encoded | false | Yes |
autowidth | boolean | If is ture, then when the tables will re-adjust the width of the table when it is first created based on the ratio of the parent element. If the parent element width changes, in order to automatically adjust the width of the table will need to implement function: setGridWidth | false | no |
caption | String | Defines a table name | Null | No, but can be modified api |
cellLayout | integer | Defined cell padding + border width. Usually you do not have to modify this value. The initial value is 5, paddingLef? 2 + paddingRight? 2 + borderLeft? 1 = 5 | 5 | no |
cellEdit | boolean | Enable or disable cell editing feature | false | Yes |
cellsubmit | String | It defines the cell contents Save in: "remote", "clientArray" | ‘remote’ | Yes |
cellurl | String | Cell url submission | Null | Yes |
colModel | array | Attribute display column is provided, it is an array object. Used to attribute: name name display column; index to the server side to the column name of the sort used; width column width; align = left alignment; the sortable whether ordering | Null | no |
colNames | array[] | Placing an array of column name must be the same size colModel | Empty array | no |
datastr | String | xmlstring or jsonstring | Null | Yes |
datatype | string | From the data type returned by the server, (table expected type of the received data). Optional type: xml, xmlstring, json, local, function | xml | Yes |
deselectAfterSort | boolean | It works only when the datatype is local. When sorting is not selected current row | true | Yes |
direction | string | The table shows the direction of the text, from left to right (ltr) or right to left (rtr). | ltr | no |
editurl | string | Url defined when the form editor | Null | Yes |
emptyrecords | string | When information on the number line shows the data returned is zero. It works only when the property is set to ture viewrecords | In the language pack | Yes |
ExpandColClick | boolean | When is true, click to expand lines of text, treeGrid can expand or shrink, just click on the picture | true | no |
ExpandColumn | string | Specify which columns to expand the tree grid, the default is the first column, it is true only in treeGrid work | Null | no |
footerrow | boolean | When is true, it will add a line on the page column | false | no |
forceFit | boolean | When is ture, adjust the column width does not change the width of the table. When shrinkToFit is false, this property is ignored | false | no |
gridstate | string | Defining the current state of the table: 'visible' or 'hidden' | visible | no |
gridview | boolean | 构造一行数据后添加到grid中,如果设为true则是将整个表格的数据都构造完成后再添加到grid中,但treeGrid, subGrid, or afterInsertRow 不能用 | false | 是 |
height | mixed | 表格高度,可以是数字,像素值或者百分比 | 150 | 否 |
hiddengrid | boolean | 当为ture时,表格不会被显示,只显示表格的标题。只有当点击显示表格的那个按钮时才会去初始化表格数据。只有当caption 属性不为空而且hidegrid为ture时才起作用 | false | 否 |
hidegrid | boolean | 启用或者禁用控制表格显示、隐藏的按钮,只有当caption 属性不为空时起效 | true | 否 |
hoverrows | boolean | 当为false时mouse hovering会被禁用 | false | 是 |
jsonReader | array | 描述json期望数据格式的数组。 | 否 | |
lastpage | integer | 只读属性,定义了总页数 | 0 | 否 |
lastsort | integer | 只读属性,定义了最后排序列的索引,从0开始 | 0 | 否 |
loadonce | boolean | 如果为ture则数据只从服务器端抓取一次,之后所有操作都是在客户端执行,翻页功能会被禁用 | false | 否 |
loadtext | string | 当请求或者排序时所显示的文字内容 | Loading.... | 否 |
loadui | string | 当执行ajax请求时要干什么。disable禁用ajax执行提示;enable默认,当执行ajax请求时的提示; block启用Loading提示,但是阻止其他操作 | enable | 是 |
mtype | string | 请求的类型:(“POST” or “GET”) | GET | 是 |
multikey | string | 只有在multiselect设置为ture时起作用,定义使用那个key来做多选。shiftKey,altKey,ctrlKey | 空值 | 是 |
multiboxonly | boolean | 只有当multiselect = true.起作用,当multiboxonly 为ture时只有选择checkbox才会起作用, | false | 是 |
multiselect | boolean | 定义是否可以多选 | false | 否 |
multiselectWidth | integer | 当multiselect为true时设置multiselect列宽度 | 20 | 否 |
page | integer | 设置初始的页码 | 1 | 是 |
pager | mixed | 指定分页栏对象,必须为一个有效的html元素。可以是'pager', '#pager', jQuery('#pager').推荐用'#pager' | 空值 | 否 |
pagerpos | string | 指定分页栏的位置 | center | 否 |
pgbuttons | boolean | 是否显示翻页按钮 | true | 否 |
pginput | boolean | 是否显示跳转页面的输入框 | true | 否 |
pgtext | string | 当前页信息 | 语言包中设置 | 是 |
prmNames | array | Default valuesprmNames: {page:“page”,rows:“rows”, sort: “sidx”,order: “sord”, search:“_search”, nd:“nd”, npage:null} 当参数为null时不会被发到服务器端 | none | 是 |
postData | array | 此数组内容直接赋值到url上,参数类型:{name1:value1…} | 空array | 是 |
reccount | integer | 只读属性,定义了grid中确切的行数。通常情况下与records属性相同,但有一种情况例外,假如rowNum=15,但是从服务器端返回的记录数是20,那么records值是20,但reccount值仍然为15,而且表格中也只显示15条记录。 | 0 | 否 |
recordpos | string | 定义了记录信息的位置: left, center, right | right | 否 |
records | integer | 只读属性,定义了返回的记录数 | none | 否 |
recordtext | string | 显示记录数信息。{0} 为记录数开始,{1}为记录数结束。 viewrecords为ture时才能起效,且总记录数大于0时才会显示此信息 | 语言包 | 是 |
resizeclass | string | 定义一个class到一个列上用来显示列宽度调整时的效果 | 空值 | 否 |
rowList | array[] | 一个数组用来调整表格显示的记录数,此参数值会替代rowNum参数值传给服务器端。如果为空则不显示,设置格式:[10,20,30]。 | [] | 否 |
rownumbers | boolean | 如果为ture则会在表格左边新增一列,显示行顺序号,从1开始递增。此列名为'rn'. | false | 否 |
rowNum | integer | 设置表格中显示的记录数,参数会被自动传到后台。如果此参数设为10,但是从服务器端返回15条记录,那么在表格中只会显示10条记录。如果设为-1则禁用此检查 | 20 | 是 |
rownumWidth | integer | 如果rownumbers为true,则可以设置column的宽度 | 25 | 否 |
savedRow | array | 只读属性,只用在编辑模式下保存数据 | 空值 | 否 |
scroll | boolean or integer | 创建一个动态滚动的表格,当为true时,翻页栏被禁用,使用垂直滚动条加载数据,且在首次访问服务器端时将加载所有数据到客户端。当此参数为数字时,表格只控制可见的几行,所有数据都在这几行中加载 | false | 否 |
scrollOffset | integer | 设置垂直滚动条宽度 | 18 | 否 |
scrollrows | boolean | 当为true时让所选择的行可见 | false | 是 |
selarrrow | array-[] | 只读属性,用来存放当前选择的行 | empty array [] | 否 |
selrow | string | 只读属性,最后选择行的id | null | 否 |
shrinkToFit | boolean | 此属性用来说明当初始化列宽度时候的计算类型,如果为ture,则按比例初始化列宽度。如果为false,则列宽度使用colModel指定的宽度 | true | 否 |
sortable | boolean | 是否可排序 | false | 否 |
sortname | string | 排序列的名称,此参数会被传到后台 | 空字符串 | 是 |
sortorder | string | 排序顺序,升序或者降序(asc or desc) | asc | 是 |
subGrid | boolean | 是否使用suggrid | false | 否 |
subGridModel | array-[] | subgrid模型 | empty array | 否 |
subGridType | mixed | 如果为空则使用表格的dataType | null | 是 |
subGridUrl | string | 加载subgrid数据的url,jqGrid会把每行的id值加到url中 | 空值 | 是 |
subGridWidth | integer | subgrid列的宽度 | 20 | 否 |
toolbar | array | 表 格的工具栏。数组中有两个值,第一个为是否启用,第二个指定工具栏位置(相对于body layer),如:[true,”both”] 。工具栏位置可选值:“top”,”bottom”, “both”. 如果工具栏在上面,则工具栏id为“t_”+表格id;如果在下面则为 “tb_”+表格id;如果只有一个工具栏则为 “t_”+表格id | [false,''] | 否 |
totaltime | integer | 只读属性,计算加载数据的时间。目前支持xml跟json数据 | 0 | 否 |
treedatatype | mixed | 数据类型,通常情况下与datatype相同,不会变 | null | 否 |
treeGrid | boolean | 启用或者禁用treegrid模式 | false | 否 |
treeGridModel | string | treeGrid所使用的方法 | nested | 否 |
treeIcons | array | 树的图标,默认值:{plus:'ui-icon-triangle-1-e',minus:'ui-icon-triangle-1-s',leaf:'ui-icon-radio-off'} | 否 | |
treeReader | array | 扩展表格的colModel且加在colModel定义的后面 | 否 | |
tree_root_level | numeric | root元素的级别, | 0 | 否 |
url | string | url | null | 是 |
userData | array | 从request中取得的一些用户信息 | empty array | 否 |
userDataOnFooter | boolean | 当为true时把userData放到底部,用法:如果userData的值与colModel的值相同,那么此列就显示正确的值,如果不等那么此列就为空 | false | 是 |
viewrecords | boolean | 是否要显示总记录数 | false | 否 |
viewsortcols | array | 定 义排序列的外观跟行为。数据格式:[false,'vertical',true].第一个参数是说,是否都要显示排序列的图标,false就是只显示当 前排序列的图标;第二个参数是指图标如何显示,vertical:排序图标垂直放置,horizontal:排序图标水平放置;第三个参数指单击功 能,true:单击列可排序,false:单击图标排序。说明:如果第三个参数为false则第一个参数必须为ture否则不能排序 | 否 | |
width | number | 如果设置则按此设置为主,如果没有设置则按colModel中定义的宽度计算 | none | 否 |
xmlReader | array | 对xml数据结构的描述 | 否 |
url | 获取数据的地址 |
datatype | 从服务器端返回的数据类型,默认xml。可选类型:xml,local,json,jsonnp,script,xmlstring,jsonstring,clientside |
mtype | ajax提交方式。POST或者GET,默认GET |
colNames | 列显示名称,是一个数组对象。 |
colModel | 对显示列属性的设置,是一个数组对象。常用到的属性:name 列显示的名称;index 传到服务器端用来排序用的列名称;width 列宽度;align 对齐方式;sortable 是否可以排序 |
pager | 定义翻页用的导航栏,必须是有效的html元素。翻页工具栏可以放置在html页面任意位置 |
rowNum | 在grid上显示记录条数,这个参数是要被传递到后台 |
rowList | 一个下拉选择框,用来改变显示记录数,当选择时会覆盖rowNum参数传递到后台 |
sortname | 默认的排序列。可以是列名称或者是一个数字,这个参数会被提交到后台 |
viewrecords | 定义是否要显示总记录数 |
caption | 表格名称 |
2、事件
事件 | 参数 | 描述 |
afterInsertRow | rowid rowdata rowelem |
此事件发生在每次插入行后 rowid 为插入的行ID rowdata 是被插入行的数据数组。格式为name:value对,name在colModel定义 rowelem 是应答元素。xml为xml行,json为所有行数据。 注意:若gridview 为true,此事件不会发生 |
beforeRequest | none | 此事件发生在任何数据请求前,但当datatype为function时不发生。 |
beforeSelectRow | rowid, e | 此事件发生在用户点击行,选中该行前。 rowid 为行的ID,e为事件对象 该事件将返回布尔值true(行被选中)或false(行未被选中)。 |
gridComplete | none | 此事件发生在表格所有数据装入和进程完成后。与datatype参数及排序分页等无关。 |
loadBeforeSend | xhr, settings |
此事件发生在XMLHttpRequest被发送前,用于修改对象属性(如headers)。 xhr 为XMLHttpRequest对象。 |
loadComplete | data | 此事件发生在每个服务器请求后。xhr 为XMLHttpRequest对象。 |
loadError | xhr, status, error |
此事件在请求失败时发生。事件有3个参数: xhr 为XMLHttpRequest对象; Satus 为错误类型描述;error 为错误对象。 |
onCellSelect | rowid, iCol, cellcontent, e |
此事件在点击表格特定单元格时发生。 rowid 为行ID;iCol 为列索引; cellcontent 为单元格中内容; e 点击事件对象。 |
ondblClickRow | rowid, iRow, iCol, e |
此事件发生在行双击后发生。 rowid为行ID;iRow 为行索引(勿与rowid混淆); iCol为列索引; e 为事件对象。 |
onHeaderClick | gridstate | 此事件发生在点击显示或隐藏表格后发生(hidegrid为true) gridstate为表格状态,有visible和hidden两个值 |
onPaging | pgButton | 此事件发生在点击page button后,填充数据前,及用户输入一个与当前页页码不同的新页码并回车时。 |
onRightClickRow | rowid, iRow, iCol, e |
此事件发生在右击行后。(此事件在Opera浏览器中无效) rowid为行ID;iRow为行索引(勿与rowid混淆) iCol为列索引; e为事件对象 |
onSelectAll | aRowids, status |
此事件发生在点击标题的复选框时发生(multiselect为true) aRowids 选定行ID的数组(哪些行的复选框与头复选框相同) status 头复选框的选定的布尔值,true为选中,false为 |
onSelectRow | rowid, status |
此事件发生在行点击后 rowid 为行ID; status 为选择状态。当multiselect为true时使用,当行被选中时返回true;为选中时返回false。 |
onSortCol | index, iCol, sortorder |
此事件发生在列排序被点击之后,数据排序前 index 为colModel 中定义的索引名iCol 为列的索引号 sortorder 为新的排序方式,asc或desc |
resizeStart | event, index | 此事件发生在列被重新定义宽度时。 event 为事件对象;index 为在colModel 中定义的列索引。 |
resizeStop | newwidth, index | 此事件发生在列被重新定义宽度后。 newwidth 为新的列宽度;index 为在colModel 中定义的列索引。 |
serializeGridData | postData | 通过此事件可以序列化传递给ajax请求的的数据。此事件将返回一个以序列化的数据。若有自定义的数据(如JSON字符串、XML字符串)要发给服务器时,可使用该事件。 |
3、方法
方法 | 参数 | 返回值 | 描述 |
addJSONData | data | none | 用传递的data(数组)填充网格。用法:假如我们从web服务器获得的数据(jsonresponse),则 var mygrid = jQuery(”#”+grid_id)[0]; var myjsongrid = eval(”(”+jsonresponse.responseText+”)”); mygrid.addJSONData(myjsongrid); myjsongrid = null; jsonresponse =null; 将填充网格。当然,myjsongrid中的数据在传递到addJSONData之前可以被操作。 |
addRowData | rowid, data, position, srcrowid |
true on success, false otherwise |
插入一新行,rowid 为新行的ID,data(数组)为新行数据,position为新行插入的位置(first为表头,last为表尾,srcrowid指定偏移位置)。Data数组的格式为:{name1:value1,name2: value2…} ,name为colModel指定的名称。 |
addXmlData | data | none | 用传入的data填充网格。用法:假如我们从web服务器获得数据 (xmlresponse),则 var mygrid = jQuery(”#”+grid_id)[0]; mygrid.addXmlData(xmlresponse.responseXML); 将填充网格。当然,xmlresponse中的数据在传递到addXmlData之前可以被操作。 |
clearGridData | clearfooter | jqGrid object | 清除网格中当前装入的数据,如果clearfooter 参数为true,则清除网格最后一行数据。 |
delRowData | rowid | true on success, false otherwise |
删除id = rowid的行。但不会删除服务器上的数据。 |
footerData | action, data, format |
jqGrid object | 此方法获得或设置网格底部数据。 action – 可设置为get(缺省)或set。 Get从底部返回name:value对象(name为colModel中的名称)。此时其他两个参数无效。 Set将data数组(对象)设置到底部。Data为colName中的名称和值对。 format – 缺省为true,表示设置时使用formatter (如果colModel中已定义)。false表示不使用formatter |
getCell | rowid, iCol |
cell content | 返回id = rowid行,column = iCol列的内容。 iCol可以是列的索引或colName中定义的名称。在编辑行或列时不能使用该方法,此时返回的不是当前值,而是原始值。 |
getCol | colname, returntype, mathoperation | array[] or value | 返回列值数组。 colname 可以是列的索引值或colModel中的名称。returntype 确定返回数组的类型,为false(缺省)时,数组只包含值。为true时为对象数组,格式为{id:rowid, value:cellvalue},id为行的id, cellvalue为单元格的值。如 [{id:1,value:1},{id:2,value:2}…] mathoperation为可选参数,可以是sum、avg和count。若此参数进行了有效设置,则返回计算后的值,若无效,则返回空数组。 |
getDataIDs | none | array[] | 返回当前网格显示数据的ID数组。无数据时返回空数组。 |
getGridParam | name | mixed value | 返回请求的参数的值。name 是options 数组中的名称,若为设置则options被返回。 |
getInd | rowid, rowcontent |
mixed | 当rowcontent 设置为false(缺省)时,返回id= rowid行的索引值。若rowcontent设置为true,则返回整行。若为找到rowid则返回false。 |
getLocalRow | rowid | row object | Return the row data from the local array stored in data parameter when the datatype is local |
getRowData | rowid or none | array{} | 返回id = rowid行的数据数组。格式为name:value对,name为colModel中的名称,value为该行的值。未找到返回空数组。在行或列编辑时此方法不可用,此时返回的不是当前值,而是原始值。 若rowid为设置,则返回网格中所有数据数组。 |
hideCol | colname or [colnames] |
jqGrid object | 根据colname或colnames数组给定的列名隐藏相应的列,列名必须是colModel中定义的名称。表格的宽度不会改变。 |
remapColumns | permutation, updateCells, keepHeader | none | 调整列的显示顺序。permutation指定调整后的顺序,如 [1,0,2] 表示第一列在第二位显示。若updateCells 设置为true,列数据将重新排序。若keepHeader 设置为true,header单元格将重新排序。 |
resetSelection | none | jqGrid object | 选择(反选)行。多选择模式下同样可用。 |
setCaption | caption | jqGrid object | 设置新的表头文字。若表头为隐藏,将显示。 |
setCell | rowid, colname, data, class, properties, forceup |
jqGrid object | 修改单元格的值、类或样式。其中: rowid为行ID;colname为列名(可以是从0开始的列的索引值); data 设置的内容,若为空,class若为字符串,将使用addClass为列加入一个类,若为数组,将直接加入CSS中;properties 设置单元格属性。 |
setGridParam | object | jqGrid object | 设置一个特定的参数。 有些参数需trigger(“reloadGrid”)才能生效。注意这个方法可以覆盖事件。名称(name:value对)为选项数组中的名称。 |
setGridHeight | new_height | jqGrid object | 动态设置网格高度。只能对单元格的高度进行设置而不是网格。new_height 可以是像素、百分比或auto。 |
setGridWidth | new_width, shrink |
jqGrid object | 动态设置网格宽度。new_width 为新宽度的像素值; shrink(true或false)作用同shrinkToFit。若不设置,则使用shrinkToFit设置。 |
setLabel | colname, data, class, properties |
jqGrid object | 设置指定列标题文字、属性和类: colname 为列名,可以是从0开始的列索引; data 为标题文字,为空则不修改; class 若为字符串,则为类名,若为数组,则直接写入CSS; properties 为标题文字的属性。 |
setRowData | rowid, data, cssprop |
true on success, false otherwise |
更新rowid指定行的数据(使用数组)。 Data数组的格式为: {name1:value1,name2: value2…} 。name为colModel中描述的名称,value为新值。cssprop若为字符串,将使用addClass为行添加类;若为数组对象,则直接加入CSS中。将data设置为false的情况下,可设置属性和类名 |
setSelection | rowid, onselectrow |
jqGrid object | 选择或反选id = rowid指定的行。若onselectrow设置为true (缺省) 则触发onSelectRow事件,否则不触发。 |
showCol | colname | jqGrid object | 显示colname 指定的列。若colname为字符串,只显示指定的列,若colname为数组 [“name1”,”name2”] 则显示name1和name2列, name必须是colModel中的名称。宽度不变。 |
trigger(“reloadGrid”) | none | none | 按当前设置重新加载网格。若datatype为xml或json,将从服务器重新请求数据。此方法适用于一个已建立的网格。注意不会改变表头,也就是说改变colModel将没有作用。你可用gridUnload,使用新colModel来重新加载。 |
updateColumns | none | none | 在拖拽表格时,同步网格宽度。用法: var mygrid=jQuery(”#grid_id”)[0]; mygrid.updateColumns(); |