存储选项不工作dgrid,与ondemandgrid完美配合

时间:2014-05-13 20:47:27

标签: dojo dgrid

我想使用Dgrid的store属性,我使用下面的代码制作dgrid表但不知道表格是不是用行填充。

 <script src="dojo/dojo.js"
            data-dojo-config="async: true"></script>
   <script>
        require(["dojo/_base/declare","dgrid/Grid","dgrid/Keyboard","dgrid/Selection","dgrid/editor","dgrid/extensions/DnD","dojo/dnd/Source", "dojo/store/Memory", "dojo/_base/lang"],
                function (declare,Grid,Keyboard,Selection,editor,DnD, DnDSource, Memory, lang){
                    var store = new Memory({
                        data: [
                            { id: 1, firstName: "Jeffrey", lastName: "Andrews", email: "jeffrey@madeupdomain.com" },
                            { id: 2, firstName: "Jenny", lastName: "Saunders", email: "jenny@madeupdomain.com" },
                        ]
                    });
                    var structure = [
                        {field: "lastName", label: "Last Name"},
                        {field: "firstName", label: "First Name"},
                        {field: "email", label: "EMail Address"}
                    ];

                    var grid = new (declare([Grid, Selection, DnD]))({
                                store: store,
                                columns: structure
                            },
                            "gridtable");
                    grid.startup();
                });

    </script>
</head>

<div id="gridtable"></div>

1 个答案:

答案 0 :(得分:0)

基本ListGrid模块并非设计为存储感知。商店知晓度通常从_StoreMixin继承,OnDemandListPagination扩展名继承。

自己扩展_StoreMixin也是可行的;例如,dgrid.io上的其中一个教程遍历very simple extension to render all data from a store at once