EASYUI DATAGRID 多列复选框CheckBox

主要实现:

用的 easyui 1.3.2

实现多个复选框列,各列互不影响。能够实现全选。主要部门用红色标记了的。

easyui datagrid 初始化:

<script>
function initTableGMAL() { $("#dg_gmal").datagrid({ url: "/Manager/PublishManager/ashx/MALOP.ashx?action=search", idField: 'MAL_ID', fit: false, fitColumns: true, singleSelect: true, width: 637, height: 280, rownumbers: true, nowrap: true, pagination: false, checkOnSelect: false, selectOnCheck: false, columns: [[ { field: 'MAL_ZHName', title: '属性', width: 200, align: 'center' } , { field: 'op1', title: ' 明细中显示:', width: 70, align: 'right' }, { field: 'op11', title: '<input id=\"detailcheckbox\" type=\"checkbox\" >', width: 30, formatter: function (value, rec, rowIndex) { return "<input type=\"checkbox\" name=\"PD\" value=\"" + rec.MAL_ID + "\" >"; } }, { field: 'op2', title: '列表中显示:', width: 70, align: 'right' }, { field: 'op22', title: '<input id=\"listcheckbox\" type=\"checkbox\" >', width: 30, formatter: function (value, rec, rowIndex) { return "<input type=\"checkbox\" name=\"PL\" value=\"" + rec.MAL_ID + "\" >"; } } ]], onLoadSuccess: function () { $("#detailcheckbox").unbind(); $("#listcheckbox").unbind();
$("input[name='PL']").unbind().bind("click", function () { //总记录数 var totolrows = $("input[name='PL']").length; //选中的记录数 var checkrows = $("input[name='PL']:checked").length; //全选 if (checkrows == totolrows) { $("#listcheckbox").attr("checked", 'checked'); } else { $("#listcheckbox").removeAttr("checked"); }
$("#pllist").val(""); var items = $("input[name='PL']:checked"); var result = ""; $.each(items, function (index, item) { result = result + "|" + item.value; }); $("#pllist").val(result); }); $("input[name='PD']").unbind().bind("click", function () { //总记录数 var totolrows = $("input[name='PD']").length; //选中的记录数 var checkrows = $("input[name='PD']:checked").length; if (checkrows == totolrows) { $("#detailcheckbox").attr("checked", 'checked'); } else { $("#detailcheckbox").removeAttr("checked"); } $("#pdlist").val(""); var items = $("input[name='PD']:checked"); var result = ""; $.each(items, function (index, item) { result = result + "|" + item.value; }); $("#pdlist").val(result); }); //全选 $("#detailcheckbox").click(function () { if ($(this).attr('checked') == 'checked') { $("input[name='PD']").attr("checked", 'checked'); } else { $("input[name='PD']").removeAttr("checked"); } $("#pdlist").val(""); var items = $("input[name='PD']:checked"); var result = ""; $.each(items, function (index, item) { result = result + "|" + item.value; }); $("#pdlist").val(result); }); $("#listcheckbox").click(function () { if ($(this).attr('checked') == 'checked') { $("input[name='PL']").attr("checked", 'checked'); } else { $("input[name='PL']").removeAttr("checked"); } $("#pllist").val(""); var items = $("input[name='PL']:checked"); var result = ""; $.each(items, function (index, item) { result = result + "|" + item.value; }); $("#pllist").val(result); }); } }); }

 </script>

保存选中的行:

<div style="padding: 15px; overflow: hidden">
    <form id="f_package_general" method="post">

        <table class="tableForm" style="width: 100%; margin-left: 2px;">
     
            <tr>
                <td style="width: 80px;">显示配置:</td>
                <td colspan="3" style="height: 280px;">
                    <table id="dg_gmal">
                    </table>
                </td>
            </tr>
        </table>
        <input type="hidden" id="pdlist" name="pdlist" value="">
        <input type="hidden" id="pllist" name="pllist" value="">
       
    </form>
</div>

 

转载于:https://www.cnblogs.com/stevenxiao/p/3610803.html

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值