简体   繁体   中英

How to get selected items in jQWidgets grid?

How can I get all selected items in my checkbox column with datafield 'selected'?

I have searched through the internet and it seems like only available tutorial is on how to get the selected row of the grid.

The following is my sample grid.

$("#jqxgrid").jqxGrid({
    width: 698,
    autoheight: true,
    source: dataAdapter,
    columnsresize: false,
    columnsheight: 25,
    sortable: true,
    editable: true,
    altrows: true,
    columns: [{
        text: labels[0],
        columntype: 'checkbox',
        threestatecheckbox: false,
        datafield: 'selected',
        width: 48,
        editable: true,
        sortable: false,
    }, {
        text: labels[1],
        datafield: 'fname',
        width: 250,
        editable: false,
    }, {
        text: labels[2],
        datafield: 'lname',
        width: 400,
        editable: false,
    }]
});

I think that you can use something like that:

   var rowindexes = $('#jqxgrid').jqxGrid('getselectedrowindexes');
     var boundrows = $('#jqxgrid').jqxGrid('getboundrows');
     var selectedrows = new Array();
     for(var i =0; i < rowindexes.length; i++)
     {
         var row = boundrows[rowindexes[i]];
         selectedrows.push(row);
     }

You can also look at this short sample: http://jsfiddle.net/zxsT6/ .

Hope this helps you.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM