zoukankan      html  css  js  c++  java
  • EasyUI 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: '权限名称',  50 },
                { field: 'DAKEYCODE', title: '权限编码',  50 },
                { field: 'MEMO', title: '描述信息',  50 },
                { field: 'DAID', title: '权限ID',  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: '权限名称',  50 },
                            { field: 'TRANSFERCODE', title: '转换编码',  50 },
                            { field: 'MEMO', title: '权限描述顺序',  50 },
                            { field: 'DAID', title: 'DAID',  50, hidden: 'true' },
                            { field: 'DAITEMID', title: 'DAITEMID',  50, hidden: 'true' }
                        ]],
                        onResize: function () {
                            $('#tbDataAuthority').datagrid('fixDetailRowHeight', index);
                        },
                        onLoadSuccess: function () {
                            setTimeout(function () {
                                $('#tbDataAuthority').datagrid('fixDetailRowHeight', index);
                            }, 0);
                        }
                    });
                    $('#tbDataAuthority').datagrid('fixDetailRowHeight', index);
                }
            })
    

    四、解析

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

  • 相关阅读:
    一款前端文件上传工具
    聊一聊最近找工作的感受
    神秘的计算机网络----(1)
    月下无限连?拒绝无休止switch!
    计算机网络---序
    验证码识别
    两数之和
    Sanic框架基础之解决CORS跨域
    Sanic框架进阶之实现异步缓存组件
    asyncio异步模块的21个协程编写实例
  • 原文地址:https://www.cnblogs.com/zhangjd/p/6203054.html
Copyright © 2011-2022 走看看