0
votes

Just started with DOJO and Dgrid. I've got this simple dgrid using a Memory store.

However the grid in the web page stay empty. Only the header is displayed.

.... @import "./dgrid/css/dgrid.css";

    <script src="./dojo/dojo.js" 
    data-dojo-config="async: true, parseOnLoad: true, isDebug: true">
    </script>

   <script language="javascript">  

    require
    (
        [
            "dojo/_base/declare", 
            "dojo/_base/array", 
            "dgrid/List",
            "dgrid/Grid",
            "dgrid/Keyboard",
            "dgrid/Editor", 
            "dgrid/extensions/ColumnResizer",
            "dijit/form/NumberTextBox",
            "dstore/Memory",
            "dojo/parser",
            "dojo/domReady!",
            "dijit/TooltipDialog",
            "dijit/form/DropDownButton",
            "dijit/layout/TabContainer", 
            "dijit/layout/ContentPane"
        ], 
        function(
            declare, arrayUtil, List, Grid, Keyboard, Editor, ColumnResizer, NumberTextBox, Memory
        ){

            var prevpds =[ 
                {itemnu: "TEST", itemna: "", batchn: "", cqty: 5, sqty: 5, sz: 5},
                {itemnu: "TEST 44", itemna: "", batchn: "", cqty: 1, sqty: 2, sz: 3}
            ];

            var pdsstore = new Memory({data: prevpds});

            var getColumns = [
                { label: "Item Number", id: "itemnu", field: "text", editor: "text" },
                { label: "Item name", id: "itemna", field: "text", editor: "text" },
                { label: "Batch number", id: "batchn", field: "text", editor: "text" },
                { label: "Concerned Qty", id: "cqty", field: "floatnumber", editor: "NumberTextBox" },
                { label: "Sold Qty", id: "sqty", field: "floatnumber", editor: "NumberTextBox" },
                { label: "Size/ Diameter", id: "sz", field: "floatnumber", editor: "NumberTextBox" }
        ];

            var PdsGrid=declare([Grid, Keyboard, Editor, ColumnResizer]);

            window.grid = new PdsGrid(
                {
                    store: pdsstore,
                    columns: getColumns

                }, "pdstable2"
            );


        }
    );
   </script>    
1
dojo store (memory/dstore) need a identity property to uniquely identify a row. Introduce a id field in the prevpds data i.e [ {id:1, itemenu:"TEST"....}, {id:2, itemenu:"TEST 44"....} and check if the dgrid renders correctly. - frank

1 Answers

0
votes

You have at least two problems.

Firstly, assuming you're using dgrid 0.4 (which I assume since you're also using dstore), you should be setting collection instead of store.

Secondly, the base List and Grid modules do not read from stores; you will want to use either OnDemandGrid or the Pagination extension.