2009-05-01 3 views
1

다음 샘플 데이터는 json 데이터에 이름 열이있는 경우에만 표시됩니다 -> 첫 번째 표에는 데이터가 표시되고 두 번째 표에는 데이터가 표시되지 않습니다.dojo 그리드에 json 데이터 소스의 이름 열이 필요합니까?

왜 이런 경우입니까?

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"}] 
} 

답변

2

검색어 속성을 요소에 추가하기 만하면됩니다. 이처럼 :

< 테이블 쿼리 = 데이터 저장소로부터 데이터를 요청할 때 그 쿼리를 수행하기 때문에 "{ID '*'}"... >

이다

+0

나는이 해결 이유 문제지만, 그렇습니다. 감사합니다. – simon

0

이름 열은 필요하지 않습니다 당신은 그러나 그리드의 데이터 저장소와 열 이름의 특성과지도를 필요합니까. 격자 '레이아웃'을 정의 할 때이 작업이 수행됩니다. '레이아웃'의 '필드'속성은 데이터 저장소의 열 이름 (정확한 속성 이름)과 '이름'속성입니다. 'Layout'은 표의 열 이름입니다.

gridLayout = [{ 
     defaultCell: { width: 8, editable: true, type: dojox.grid.cells._Widget, styles: 'text-align: right;' }, 
     rows: [ 
      { name: 'Id', field: 'id', editable: false /* Can't edit ID's of dojo.data items */ }, 
      { name: 'Date', field: 'col8', width: 10, 
       type: dojox.grid.cells.DateTextBox, 
       formatter: formatDate, 
       constraint: {formatLength: 'long', selector: "date"}}, 
      { name: 'Priority', styles: 'text-align: center;', field: 'col1', 
       type: dojox.grid.cells.ComboBox, 
       options: ["normal", "note", "important"], width: 10}, 
      { name: 'Mark', field: 'col2', width: 3, styles: 'text-align: center;', 
       type: dojox.grid.cells.CheckBox}, 
      statusCell, 
      { name: 'Message', field: 'col4', styles: '', width: 10, 
       type: dojox.grid.cells.Editor, editorToolbar: true }, 
      { name: 'Amount', field: 'col5', formatter: formatCurrency, constraint: {currency: 'EUR'}, 
       widgetClass: dijit.form.CurrencyTextBox }, 
      { name: 'Amount', field: 'col5', formatter: formatCurrency, constraint: {currency: 'EUR'}, 
       widgetClass: dijit.form.HorizontalSlider, width: 10} 
     ] 
    }]; 
관련 문제