Prabhakar Pentela
Prabhakar Pentela

Reputation: 5

Disable Header Check box if all rows are disabled in JQGRID?

I am using JQGRID with MultiSelect="true" option. i want to disable the Header Checkbox (Select All) if all the row check boxes are disabled? did wrote the following code on load Complete to disable/enable the row checkboxes. For lines, I did use $("#jqg_linesGrid_"+rowId).attr("disabled", true), what should I use for Header Check box?

$.subscribe("loadComplete", function(event, status, data){

    var grid = $("#linesGrid");
    var ids = grid.jqGrid('getDataIDs');
    for(var i=0;i < ids.length;i++){
        var rowId = ids[i];
        var rowData = jQuery('#linesGrid').jqGrid ('getRowData', rowId);
         if(rowData.fieldValue){
                $("#jqg_linesGrid_"+rowId).attr("disabled", true);
                         }

    }
});

Thanks,

Upvotes: 0

Views: 1268

Answers (1)

Mohamed-Yousef
Mohamed-Yousef

Reputation: 24001

For sure we need to know more html code but to know the concept of how make that look at this code

$('.checkb').on('click',function(){
    var count = 0;
    $('.checkb').each(function(){
        if($(this).is(':checked')){
            count = count + 1;
        }
    });
    if(count == 0){
        $('.checkb:first-child').attr('disabled',true);
    }else{
        $('.checkb:first-child').attr('disabled',false);
    }
});

and see DEMO just change selectors .. Hope it help.. NOTE: this code in click event .. you can use it in any event you want

Upvotes: 0

Related Questions