开发者

jqGrid with multiselect how to check all checkboxes and top one at load?

How can I instruct jqGrid to directly sel开发者_如何学Pythonect all checkboxes when I instantiate it? Can this be done as a parameter in the colModel somehow?


I tried the solutions above but it would not select the checkboxes. This Solved the problem.

$('.cbox').trigger('click').attr('checked', true);

Fixes the issue of checking boxes and you only have to click on it once to uncheck.

Make sure you do this after the jqgrid has loaded.


You may want to take a look at setSelection. From jqGrid Documentation

setSelection(rowid, onsetselection)
Toggles a selection of the row with id = rowid; if onsetselection is true (the default) then the event onSetRow is launched, otherwise it is not 

Another way you can do this is by marking all checkboxes int the grid:

$('.cbox').click();

But you want to call this after the grid is complete, so call it inside gridComplete event:

    gridComplete: function() {
      $('.cbox').click();
    }


I tried the

$('.cbox').click();

in the gridComplete but that didn't work. Then I tried this:

$('.cbox').attr('checked', true);

and that worked, it set all checkboxes to checked but what happened then is that I needed to click twice to uncheck one.

What worked for me was:

$('.cbox').trigger('click');


Here is a function that will select all rows. It follows many of the same suggestions made by Daniel:

gridSelectAll : function(divID){
    // Select header checkbox (no jqGrid API for this, unfortunately)
    var parentView = divID.replace("#", "#gview_");
    jQuery(parentView).find("#cb_jqg").click();

    // Loop again to select all rows
    var data = jQuery(divID).getDataIDs();
    for(var i=0; i < data.length;i++){
        jQuery(divID).setSelection(data[i]); // All selected by default
    }
}

You can call this from the GridComplete event to automatically check all of the boxes at load time.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜