1. getLocalRow (推荐使用)
Return the row data from the local array stored in data parameter when
the datatype is local
根据官方说明,当jqGri的datatype为local时,getLocalRow从data参数中,存储在本地的数组中获取行数据.
$("#grid").getLocalRow(rowid);
2. getRowData
Returns an array with data of the requested id = rowid. The returned array is of type name:value, where the name is a name from colModel and the value from the associated column in that row. It returns an empty array if the rowid can not be found.
- Do not use this method when you are editing the row or cell. This will return the cell content and not the actuall value of the input element.
- the performance of this method becomes an issue. Do not use this method in the body of “for” and “when”. (When calling this method, it will calculates the row datas one time.)
If the rowid is not set the method return all the data from the grid in array
值得注意的是上面的两点:
1) 请不要在编辑行或者列时使用此方法,这个方法将会返回input元素的html内容而不是所期待的值.
2)不要在 for循环或者when 中使用此方法,性能上会有所影响,数据多时可能会导致很慢.
举个实际的例子,当你在使用有checkbox的自定义时使用此方法,那么返回的对象中,checkbox相关的内容将是你的自定义内容:
<input type="checkbox" name="gridChks" class="gridChks" onclick="xxx" checked="true/">
本文介绍了jqGrid获取当前选中行数据的两种方法:getLocalRow(推荐使用)和getRowData。getLocalRow从本地数据数组中获取行数据,而getRowData返回指定rowid的数据,但在编辑时会返回cell内容而非实际值。注意,getRowData在大量数据时可能影响性能,并且如果没有设置rowid,将返回整个网格数据。在使用包含checkbox的自定义列时,使用getRowData会返回checkbox的自定义内容。


被折叠的 条评论
为什么被折叠?



