Kim Honoridez
Kim Honoridez

Reputation: 997

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,
    }]
});

Upvotes: 0

Views: 3602

Answers (1)

scripto
scripto

Reputation: 2297

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.

Upvotes: 2

Related Questions