Gridx 显示控件故障一例

Gridx显示控件代码

HTML

<!DOCTYPE html>
<html>
<head>
    <title>Widget in Grid Cell Test</title>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8"></meta>
    <style type="text/css">
        .gridx {
            width: 1000px;
            height: 420px;
        }
    </style>
    <link rel='stylesheet' href="dijit/themes/claro/claro.css" />
    <link rel="stylesheet" href="gridx/resources/claro/Gridx.css" />
    <script type="text/javascript" src="dojo/dojo.js" data-dojo-config="async: true"></script>
</head>
<body class='claro'>
    <div id="gridContainerPost"></div>
</body>
</html>

Script脚本

 <script type="text/javascript">
        require(['dojo/store/Memory',
            'gridx/Grid',
            'gridx/core/model/cache/Sync',
            'dijit/form/CheckBox',
            'gridx/modules/CellWidget'], function(Store,Grid,Cache,CheckBox,CellWidget) {
            var store,gridPost;
            store = new Store({data: [{ SelPost: true, ID: "admin", Name: "ssss"}] });
            console.log('new Store');
            gridPost = new Grid({
                cacheClass: Cache,
                store: store,
                structure:
                [
                    { field: "SelPost", name: "选中", width: "56px", widgetsInCell: true,decorator: function () {
                            return '<span data-dojo-type="dijit.form.CheckBox" data-dojo-attach-point="cb"></span>';
                        },setCellValue: function (data) {
                            this.cb.set('value', data);
                        }
                    },
                    { field: "ID", name: "岗位编号" },
                    { field: "Name", name: "岗位名称" }
                ],
                modules:
                [
                    CellWidget
                ],
                autoHeight: true,
                pageSize: 110
            });
            console.log('new Grid');
            gridPost.placeAt("gridContainerPost");
            gridPost.startup();
        });
    </script>

显示问题

不能显示CheckBox,代码调试发现row.id 是null所以不能正常显示。在CellWidget.js文件中的_showDijits函数

经过多种方法实验发现使用Cache好用。但是tests文件夹下的test_grid_cellwidget也是Memory好用。

最后调试发现:dojo/store/Memory唯一关键字的字段名没有指定,因此造成row.id为null

store = new Store({data: [{ SelPost: true, ID: "admin", Name: "ssss"}] });

修改如下

store = new Store({ idProperty:"ID", data: [{ SelPost: true, ID: "admin", Name: "ssss"}] }); //测试ok!

使用Dojo或者Gridx的最大考验就是耐心、仔细。往往他的例子都不能正常运行,必须更改!

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值