的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/
它的工作@喬治... – 2015-04-02 08:36:56