EasyUI DataGrid - 嵌套的DataGrid

实现效果:

一、在页面头部引用视图脚本JS文件

  <script src="@Url.Content("~/Resources/EasyUI/plugins/datagrid-detailview.js")" type="text/javascript"></script>

二、创建主DataGrid视图

<div id="table">
    <table id="tbDataAuthority"></table>
</div>

三、设置详细DataGrid 显示

        $('#tbDataAuthority').datagrid({
            striped: true,
            url: '/User/BindDataAuthorityGrid',
            iconCls: 'icon-edit', //图标
            singleSelect: true,
            autoRowHeight: false,
            rownumbers: true,
            fitColumns: true,
            border: false,
            pagination: true, //是否分页
            columns: [[
            { field: 'DANAME', title: '权限名称', width: 50 },
            { field: 'DAKEYCODE', title: '权限编码', width: 50 },
            { field: 'MEMO', title: '描述信息', width: 50 },
            { field: 'DAID', title: '权限ID', width: 50, hidden: true },
            ]],
            view: detailview,
            detailFormatter: function (index, row) {
                return '<div style="padding:5px"><table id="tbDataAuthorityItem-' + index + '"></table></div>';
            },
            onExpandRow: function (index, row) {
                $('#tbDataAuthorityItem-' + index).datagrid({
                    url: '/User/BindDetailGridListByDaId/?daId=' + row.DAID,
                    fitColumns: true,
                    singleSelect: true,
                    rownumbers: true,
                    loadMsg: '',
                    height: 'auto',
                    columns: [[
                        { field: 'DAITEMNAME', title: '权限名称', width: 50 },
                        { field: 'TRANSFERCODE', title: '转换编码', width: 50 },
                        { field: 'MEMO', title: '权限描述顺序', width: 50 },
                        { field: 'DAID', title: 'DAID', width: 50, hidden: 'true' },
                        { field: 'DAITEMID', title: 'DAITEMID', width: 50, hidden: 'true' }
                    ]],
                    onResize: function () {
                        $('#tbDataAuthority').datagrid('fixDetailRowHeight', index);
                    },
                    onLoadSuccess: function () {
                        setTimeout(function () {
                            $('#tbDataAuthority').datagrid('fixDetailRowHeight', index);
                        }, 0);
                    }
                });
                $('#tbDataAuthority').datagrid('fixDetailRowHeight', index);
            }
        })

四、解析

   当用户点击展开按钮('+')时,'onExpandRow' 事件将被触发,就会渲染一个子DataGrid。

 

转载于:https://www.cnblogs.com/zhangjd/p/6203054.html

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值