jQWidgets Forums

jQuery UI Widgets Forums Grid Check only filtered rows

This topic contains 2 replies, has 2 voices, and was last updated by  zack.wd 11 years, 4 months ago.

Viewing 3 posts - 1 through 3 (of 3 total)
  • Author
  • Check only filtered rows #48649

    zack.wd
    Participant

    Hi,
    I use the checkbox to select the rows in jqxgrid to process it further as shown here : http://www.jqwidgets.com/jquery-widgets-demo/demos/jqxgrid/index.htm#demos/jqxgrid/checkboxselection.htm .My problem is when i filter the data in a column using filterable row and click on the checkall on the left top of jqxgrid, whole grid rows are selected instead of ONLY the filtered rows.Here is the code of what happens after selection using checkbox :

    $('#jqxgrid').bind('rowselect', function (event)
                    {
                    var rows            = $("#jqxgrid").jqxGrid('selectedrowindexes');
                    var selectedRecords = new Array();
                    var value           = new Array();
                    var gnos           = new Array();
                    var ros          = new Array();
                    var gdates         = new Array();
                    var rlnos         = new Array();
                    var ss        = new Array();
                    var brch          = new Array();
    
                    for (var m = 0; m < rows.length; m++)
                    {
                         gnos[m] = $('#jqxgrid').jqxGrid('getcellvalue', rows[m], "gno");
                         ros[m] = $('#jqxgrid').jqxGrid('getcellvalue', rows[m], "ro");
                         gdates[m] = $('#jqxgrid').jqxGrid('getcellvalue', rows[m], "gdate");
                         rlnos[m] = $('#jqxgrid').jqxGrid('getcellvalue', rows[m], "rlno");
                         ss[m] = $('#jqxgrid').jqxGrid('getcellvalue', rows[m], "se");
                         brch[m] = $('#jqxgrid').jqxGrid('getcellvalue', rows[m], "brch");
    
                    }
    
                       document.getElementById("ginos").value=JSON.stringify(gnos);
                       document.getElementById("ricnos").value=JSON.stringify(ros);
                       document.getElementById("gidates").value=JSON.stringify(gdates);
                       document.getElementById("reelnos").value=JSON.stringify(rlnos);
                       document.getElementById("supcodes").value=JSON.stringify(ss);
                       document.getElementById("branch").value=JSON.stringify(brch);
                    });
    

    Is there anything wrong when i select rows?

    Check only filtered rows #48651

    Peter Stoev
    Keymaster

    Hi zack.wd,

    That is correct. The selectAll checkbox selects all rows loaded into the Grid. It does not matter whether the Grid is filtered or not. That is by design. We will consider whether to add an option for selection only of the visible rows.

    Best Regards,
    Peter Stoev

    jQWidgets Team
    http://www.jqwidgets.com/

    Check only filtered rows #48656

    zack.wd
    Participant

    Hi Peter,
    Thanks for the help.Is there a work around for this – I am thinking of adding it as check box column with a button which checks for the the rows selected instead of the default check all/uncheck all.

    
    // select or unselect rows when the checkbox is clicked in the grid.
                $("#jqxgrid").bind('cellendedit', function (event) {
                    if (event.args.value) {
                        $("#jqxgrid").jqxGrid('selectrow', event.args.rowindex);
                    }
                    else {
                        $("#jqxgrid").jqxGrid('unselectrow', event.args.rowindex);
                    }
                });
    
    $("#checkallbutton").click(function()
                {
                    var rowscount = $("#jqxgrid").jqxGrid('getdatainformation').rowscount;
                    var rows = $('#jqxgrid').jqxGrid('getrows');
                    $("#jqxgrid").jqxGrid('beginupdate');
    
                    var gs    = new Array();
                    var rs   = new Array();
                    var gdates  = new Array();
                    var rlnos  = new Array();
                    var ss = new Array();
                    var brch   = new Array();
    
                    for (var m = 0; m < rows.length; m++)
                    {
    
                         gs[m] = $('#jqxgrid').jqxGrid('getcellvalue', rows[m], "gno");
                         rs[m] = $('#jqxgrid').jqxGrid('getcellvalue', rows[m], "rno");
                         gdates[m] = $('#jqxgrid').jqxGrid('getcellvalue', rows[m], "gdate");
                         rlnos[m] = $('#jqxgrid').jqxGrid('getcellvalue', rows[m], "rlno");
                         ss[m] = $('#jqxgrid').jqxGrid('getcellvalue', rows[m], "se");
                         brch[m] = $('#jqxgrid').jqxGrid('getcellvalue', rows[m], "brch");
    
                         $("#jqxgrid").jqxGrid('setcellvalue', m, 'available', true, false);
                    }
    
                       document.getElementById("ginos").value=JSON.stringify(gs);
                       document.getElementById("ricnos").value=JSON.stringify(rs);
                       document.getElementById("gidates").value=JSON.stringify(gdates);
                       document.getElementById("reelnos").value=JSON.stringify(rlnos);
                       document.getElementById("supcodes").value=JSON.stringify(ss);
                       document.getElementById("branch").value=JSON.stringify(brch);
                       $("#jqxgrid").jqxGrid('selectallrows');
                       $("#jqxgrid").jqxGrid('endupdate');
    
                });
Viewing 3 posts - 1 through 3 (of 3 total)

You must be logged in to reply to this topic.