• Easyui-datagrid groupview分组后勾选问题


    上面datagrid对应的代码如下:

     1 $('#tbCheckOut').datagrid({
     2             title: '待分配库位',
     3             iconCls: 'icon-search',
     4              1112,
     5             height: 500,
     6             rownumbers: true,
     7             idField: 'ID',
     8             sortOrder: 'desc',
     9             sortName: 'ID',
    10             remoteSort: false,
    11             nowrap: false,
    12             collapsible: true,
    13             striped: true,
    14             fitColumns: false,
    15             pagesize: 10,
    16             pagination: true,
    17             url: '/StockOut/WebAjax/ProcCheckOutList.ashx',
    18             queryParams: convertArray($('#fmSearch').serializeArray()),
    19             onLoadSuccess: function (data) {
    20                 $('#tbCheckOut').datagrid('collapseGroup'); //设置折叠
    21             },
    22             onDblClickCell: function (index, field, value) {
    23             },
    24             columns: [[
    25             { field: 'singlechk',  50, checkbox: true},
    26             { field: 'CheckOutType', title: '单据类型',  80, align: 'center', sortable: true, formatter: function (value, row) {
    27                 return FGetCheckOutTypeInfo(value);
    28             }
    29             },
    30             { field: 'PostTime', title: '下单日期',  70, align: 'center', sortable: true, formatter: function (value, row) {
    31                 return ChangeShortDateFormat(value);
    32             }
    33             },
    34             { field: 'K3OrderCode', title: '编号',  120, align: 'center', sortable: true },
    35             { field: 'SerialNo', title: '流水号',  120, align: 'center', sortable: true },
    36             { field: 'CustomName', title: '客户',  200, align: 'center', sortable: true, formatter: function (value, row) {
    37                 var rtnStr = value; //todo 截取
    38                 return rtnStr;
    39             }
    40             },
    41             { field: 'ItemSNCode', title: '物料编码',  120, align: 'center', sortable: true },
    42             { field: 'SKUCode', title: 'SKU',  50, align: 'center', sortable: true },
    43             { field: 'ItemSNName', title: '物料名称',  250, align: 'center', sortable: true },
    44             { field: 'AssignNum', title: '计划',  50, align: 'center', sortable: true },
    45             { field: 'ActualNum', title: '实际',  50, align: 'center', sortable: true },
    46             { field: 'HasAllotedNum', title: '已分配',  50, align: 'center', sortable: true },
    47             { field: 'UnitName', title: '单位',  50, align: 'center', sortable: true },
    48             { field: 'SpecificationsName', title: '规格型号',  60, align: 'center', sortable: true },
    49             { field: 'WarehouseName', title: '发货仓库',  100, align: 'center', sortable: true },
    50             { field: 'ChannelName', title: '渠道',  30, align: 'center', sortable: true },
    51             { field: 'ID', title: '操作',  120, align: 'center', formatter: function (value, row) {
    52                 var rtnStr = "";
    53                 if (row.Status == 0) {
    54                     rtnStr = '<a href="javascript:void()" class="gridAColor" onclick="FProcTask(1,' + value + ')">自动出库</a> <a href="javascript:void()" onclick="FProcTask(0,' + value + ')" class="gridAColor" >手动出库</a>';
    55                 }
    56                 return rtnStr;
    57             }
    58             }
    59         ]],
    60             groupField: 'K3OrderCode',
    61             view: groupview,
    62 
    63             groupFormatter: function (value, rows) {
    64                 var rtnStr = "";
    65                 rtnStr += '<input type="checkbox" onclick="FGPCkbClick(this)" helpGPVal="' + value + '" name="gpChk" />';
    66                 rtnStr += value + ' 单据数量=' + rows.length + '条';
    67                 var sumAssignNum = 0;
    68                 var sumActualNum = 0;
    69                 for (var i = 0; i < rows.length; i++) {
    70                     sumAssignNum += rows[i].AssignNum;
    71                     sumActualNum += rows[i].ActualNum;
    72                 }
    73                 rtnStr += " 计划量=" + sumAssignNum;
    74                 rtnStr += " 实际量=" + sumActualNum;
    75                 return rtnStr;
    76             }
    77         });
    View Code


    下面是实现该功能的几个js函数

     1  //分组ckb事件
     2     function FGPCkbClick(obj) {
     3         var gpVal = $(obj).attr("helpGPVal");
     4         var isChecked = $(obj).attr('checked') == 'checked' ? true : false;
     5         selectByGroup(isChecked, gpVal, '#tbCheckOut');
     6     }
     7     //分组选中 
     8     function selectByGroup(checked, value, tableIdSelector) {
     9         var groups = $(tableIdSelector).datagrid("options").view.groups;
    10         var rows;
    11         for (var i = 0; i < groups.length; i++) {
    12             if (groups[i].value == value) {
    13                 rows = groups[i].rows;
    14                 break;
    15             }
    16         }
    17         if (checked) {
    18             for (var i = 0; i < rows.length; i++) {
    19                 $(tableIdSelector).datagrid("selectRow", $(tableIdSelector).datagrid("getRowIndex", rows[i]));
    20             }
    21         }
    22         else {
    23             for (var i = 0; i < rows.length; i++) {
    24                 $(tableIdSelector).datagrid("unselectRow", $(tableIdSelector).datagrid("getRowIndex", rows[i]));
    25             }
    26         }
    27     }
    28     //datagrid顶部ckb事件
    29     function BoundCkbAllClick() {
    30         $('.datagrid-header-check input').click(function () {
    31             var isChecked = $(this).attr('checked');
    32             $('input[name="gpChk"]').each(function (index, elemetn) {
    33                 //alert('90:' + $(this).attr('helpgpval'));
    34                 if (isChecked == 'checked') {
    35                     $(this).attr('checked', isChecked);
    36                 } else {
    37                     $(this).removeAttr('checked');
    38                 }
    39 
    40             });
    41         });
    42     }
    View Code

     感谢园友white knight提供的一个方法,完美解决

  • 相关阅读:
    Zero-shot Relation Classification as Textual Entailment (Abiola Obamuyide, Andreas Vlachos, 2018)阅读笔记:Model
    高阶Erlang:超大只的问答房间
    高阶的Parser:可变运算优先级
    Erlang练习2:火烈鸟
    Erlang实现的模拟kaboose(山寨kahoot)
    Prolog模拟社交圈
    08-bootcss
    07-jQuery
    06-字符串、表单form、input标签
    05-有名/无名函数
  • 原文地址:https://www.cnblogs.com/kungge/p/4684829.html
Copyright © 2020-2023  润新知