jQWidgets Grid的“getboundrows”方法返回所有行 - 示例:
var data = generatedata(5);
var source = {
localdata: data,
datafields: [{
name: 'firstname',
type: 'string'
}, {
name: 'lastname',
type: 'string'
}, {
name: 'productname',
type: 'string'
}, {
name: 'date',
type: 'date'
}, {
name: 'quantity',
type: 'number'
}, {
name: 'price',
type: 'number'
}],
datatype: "array"
};
var adapter = new $.jqx.dataAdapter(source);
$("#jqxgrid").jqxGrid({
width: 600,
height: 100,
theme: 'energyblue',
source: adapter,
sortable: true,
selectionmode: 'singlecell',
columns: [{
text: 'First Name',
datafield: 'firstname',
columngroup: 'Name',
width: 90
}, {
text: 'Last Name',
columngroup: 'Name',
datafield: 'lastname',
width: 90
}, {
text: 'Product',
datafield: 'productname',
width: 170
}, {
text: 'Order Date',
datafield: 'date',
width: 160,
cellsformat: 'dd-MMMM-yyyy'
}, {
text: 'Quantity',
datafield: 'quantity',
width: 80,
cellsalign: 'right'
}, {
text: 'Unit Price',
datafield: 'price',
cellsalign: 'right',
cellsformat: 'c2'
}]
});
$("#jqxbutton").jqxButton({
theme: 'energyblue',
width: 200,
height: 30
});
$('#jqxbutton').click(function () {
var rows = $('#jqxgrid').jqxGrid('getboundrows');
var result = "";
for (var i = 0; i < rows.length; i++) {
var row = rows[i];
result += row.firstname + " " + row.lastname + " " + row.productname + " " + row.date + " " + row.quantity + " " + row.price + "\n";
}
alert(result);
});
http://jsfiddle.net/jqwidgets/3LLVW/。有了所选行的索引,您可以遍历行并检查行的 boundindex 是否在 rowIndexes 数组内。如果不是,则未选择该行。
示例:http: //jsfiddle.net/jqwidgets/yzqswcvr/