1

次のサンプル データでは、json データに名前列が含まれている場合にのみグリッドに表示されます。最初のグリッドにはデータが表示され、2 番目のグリッドには表示されません。

これはなぜですか?

index.html: 道場グリッド

    <link rel="stylesheet" type="text/css" href="http://ajax.googleapis.com/ajax/libs/dojo/1.3/dijit/themes/tundra/tundra.css" />
    <link rel="stylesheet" type="text/css" href="http://ajax.googleapis.com/ajax/libs/dojo/1.3/dojo/resources/dojo.css" />
    <link rel="stylesheet" type="text/css" href="http://ajax.googleapis.com/ajax/libs/dojo/1.3/dojox/grid/_grid/tundraGrid.css">
    <script type="text/javascript" 
            src="http://ajax.googleapis.com/ajax/libs/dojo/1.3/dojo/dojo.xd.js" 
            djConfig="parseOnLoad: true, isDebug: true">
    </script>

    <script type="text/javascript">
      dojo.require("dojo.parser");
      dojo.require("dojox.grid.Grid");
      dojo.require("dojo.data.ItemFileReadStore");
    </script>

  </head>
  <body class="tundra">
   <span dojoType="dojo.data.ItemFileReadStore" 
            jsId="withNameStore" 
            url="WithNameColumn.json"
            clearOnClose="true">
    </span>
    <table id="withNameGrid"
           dojoType="dojox.grid.Grid" 
           store="withNameStore"
           clientSort="true"
           style="width: 20em; height: 20em;">
        <thead>
           <tr>
              <th field="ID" >ID</th>
              <th field="test">Test</th>
           </tr>
        </thead>
    </table>
    <span dojoType="dojo.data.ItemFileReadStore" 
          jsId="withoutNameStore" 
          url="WithoutNameColumn.json"
          clearOnClose="true">
    </span>
    <table id="withoutNameGrid" 
           dojoType="dojox.grid.Grid" 
           store="withoutNameStore"
           clientSort="true"
           style="width: 20em; height: 20em;">
        <thead>
           <tr>
              <th field="ID" >ID</th>
              <th field="test">Test</th>
           </tr>
        </thead>
    </table>
  </body>
</html>

WithNameColumn.json:

{
  "identifier":"ID",
  "label":"test",
  "items":
    [{"ID":2,"name":"name1","test":"dog"},
     {"ID":3,"name":"name2","test":"cat"},
     {"ID":4,"name":"name3","test":"mouse"}]
}

WithoutNameColumn.json:

{
  "identifier":"ID",
  "label":"test",
  "items":
    [{"ID":2,"test":"dog"},
     {"ID":3,"test":"cat"},
     {"ID":4,"test":"mouse"}]
}
4

2 に答える 2

2

要素にクエリ属性を追加するだけです。このような:

<table query="{ID:'*'}" ...>

これは、データ ストアからデータを要求するときにクエリを実行するためです。

于 2009-08-25T08:13:58.877 に答える