jqgrid: multiselect and disable check (conditional)

前端 未结 5 1735
心在旅途
心在旅途 2020-12-01 04:51


I love jqGrid but sometimes things seem more complicated than they should be.
What I would like to achieve is to have a checkbox on each row so that a user can choo

5条回答
  •  悲&欢浪女
    2020-12-01 05:10

    Great answer from Oleg, I would also add code to deselect disabled rows, complete onSelectAll function below.

    onSelectAll: function(aRowids,status) {
        if (status) {
            // uncheck "protected" rows
            var cbs = $("tr.jqgrow > td > input.cbox:disabled", grid[0]);
            cbs.removeAttr("checked");
    
            //modify the selarrrow parameter
            grid[0].p.selarrrow = grid.find("tr.jqgrow:has(td > input.cbox:checked)")
                .map(function() { return this.id; }) // convert to set of ids
                .get(); // convert to instance of Array
    
            //deselect disabled rows
            grid.find("tr.jqgrow:has(td > input.cbox:disabled)")
                .attr('aria-selected', 'false')
                .removeClass('ui-state-highlight');
        }
    }
    

提交回复
热议问题