jqGrid建表体会

在jquery框架中,常常会利用到jqGrid建立表格,这也是比较常见的形式:

1、加载相应的jqGrid文件包;

2、列表中显示的常规属性必须与model属性保持一致:

colNames:['Id','角色名称','允许所有监测器组','允许所有策略组', '更新者','更新时间','操作'],
            colModel:[{
                align : 'center',
                   key:true,
                   name:'id',//
                   index:'id',
                   width:500,
                   hidden:true,
                   },{
                   align : 'center',            
                name : 'roleName',//
                index : 'roleName',
                width : 500,
                hidden:false,
                   },{
                   align : 'center',            
                name : 'isAllNetPort',
                index : 'isAllNetPort',
                width : 500,
                hidden:false,
                   },{
                   align : 'center',            
                name : 'isAllStraGrp',
                index : 'isAllStraGrp',
                width : 500,
                hidden:false,
                   },{
                   align : 'center',            
                name : 'updater',//
                index : 'updater',
                width : 500,
                hidden:false,
                   },{
                   align : 'center',            
                name : 'updateTime',//
                index : 'updateTime',
                width : 500,
                hidden:false,
                   },{
                   align : 'center',
                   name:'操作',
                   index:'operation',
                   width:1500,
                   resizable:false,
                   }],
               rowNum:20,
               rowList:[20,30,40],
               pager: '#'+pagerId,
               sortname: 'id',
               scroll:false,
               autowidth : true,
               hidegrid: false,
               altRows : false,
               viewrecords : true,
              multiselect : true,
              sortorder : 'desc',
              height:'auto',
              caption : "<span class='glyphicon glyphicon-th-list'></span>角色管理列表",
             });

//属性保持一致性。

3、外键的理解:一般在领域模型model中,非常规类型的属性,即是对象类型的属性,如果在列表中这些属性是不被直接显示的,则做成外键过滤掉,当然列表中某列显示的是引用的是数据库中别的表的属性,需要添加外键显示:

   try
        {
           JqGridResponseBean jqGridObject = new JqGridResponseBean();
           JsonConfig cfg = JsonFilter.getFilter(new String[] { "rolemenu",
                   "adminrole", "roleMonitorGroup", "rolePolicyGroup","roleEventFilter","roleoperation"});// 过滤外键
           JSONObject jsonObject = JSONObject.fromObject(jqGridObject, cfg);
           writeRepnonseJson(jsonObject, response);
        }
        catch (Exception e)
        {
            this.logger.error(e.getMessage(), e);
            writeRepnonse("Grid查找响应记录失败.", response);
        }

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值