2015-10-21 67 views
0

剛剛開始使用DOJO和Dgrid。 我有這個簡單的dgrid使用內存存儲。Dgrid Store問題:數據不顯示

但是網頁中的網格保持空白。僅顯示標題。

.... @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>  
+0

道場存儲(存儲器/ dstore)需要一個標識屬性來唯一地標識的行。在'prevpds'數據中引入'id'字段,例如'[{id:1,itemenu:「TEST」....},{id:2,itemenu:「TEST 44」....}如果dgrid呈現正確。 – frank

回答

0

您至少有兩個問題。

首先,假設您使用的是dgrid 0.4(我假設您也使用dstore),您應該設置collection而不是store。其次,基本列表和網格模塊不從商店中讀取;然而,基本列表和網格模塊並不從商店中讀取;因此,基本列表和網格模塊不從商店讀取。您將需要使用OnDemandGrid或分頁擴展。