我有以下网格:
$(function(){
$("#poGrid").jqGrid({
url:'URL',
datatype: 'json',
mtype: 'GET',
colNames:[],
pager: '#poPager',
rowNum:10,
rowList:[10,20,30],
sortname: 'orderID',
sortorder: 'ASC',
jsonReader : { repeatitems: false },
viewrecords: true,
gridview: true,
caption: ' ',
multiselect: true,
height: "100%",
colModel :[
{name:'orderID', label:'Order ID', width:80, align: 'center'},
{name:'orderName', label:'Order Name', width:250},
{name:'countTotal', label:'Count Total', width:80},
{name:'orderTotal', label:'Order Total', width:80},
{name:'orderDate', label:'Order Date', width:100}
],
onSelectRow: function(id){
var grid = jQuery('#poGrid');
var sel_row = grid.jqGrid('getGridParam', 'selrow');
var sel_id = grid.jqGrid('getCell', sel_row, 'orderID');
setOrderIDs(id,sel_id);
}
});
我只想弄清楚在运行setOrderIDs
函数之前是否已选中或取消选择触发onSelectRow的行。如果它被取消选择触发,我不想运行该函数。
对此的任何帮助都会很棒。
谢谢!
答案 0 :(得分:3)
这很容易。您应该测试onSelectRow的第二个布尔参数的值:status
onSelectRow: function (id, status) {
if (status) {
// row is selected
}
}