jqgrid的分组复选功能

$("#gridTable").on("change", "input[type=checkbox]", function (e) {
            var currentCB = $(this);
            var grid = jQuery('#gridTable');
            var isChecked = this.checked;
            if (currentCB.is(".groupHeader")) { //if group header is checked, to check all child checkboxes
                var checkboxes = currentCB.closest('tr').nextUntil('tr.gridTableghead_0').find('.cbox[type="checkbox"]');
                checkboxes.each(function () {
                    if (!this.checked || !isChecked)
                        grid.setSelection($(this).closest('tr').attr('id'), true);
                });
            } else {  //when child checkbox is checked
                var allCbs = currentCB.closest('tr').prevAll("tr.gridghead_0:first").nextUntil('tr.gridghead_0').andSelf().find('[type="checkbox"]');
                var allSlaves = allCbs.filter('.cbox');
                var headerCB = allCbs.filter(".groupHeader");
                var allChecked = !isChecked ? false : allSlaves.filter(":checked").length === allSlaves.length;
                headerCB.prop("checked", allChecked);
            }
        });
groupText: ['<input type="checkbox" class="groupHeader" style="top:3px"/>'&nbsp;{1}&nbsp;</span>条 '],

 

上一篇:HTML + CSS + JavaScript 实现勾选动态表格中的记录


下一篇:jquery单选框redio设置checked属性无效的原因