2010-05-03 5 views
1

내 페이지에 콤보 상자와 데이터 격자가 있습니다. 사용자가 콤보 상자 값을 변경하면 새로 선택한 부모의 자식 세부 정보로 눈금을 업데이트해야합니다. Dojo 콤보 상자 및 DataGrid를 사용하여 어떻게이 작업을 수행 할 수 있습니까?콤보 상자 값 변경시 새 저장소 값으로 dojo 데이터 격자 업데이트/새로 고침

다음 코드 단편은 나를 위해 작동하지 않습니다. 새로운 json 데이터로 그리드의 setStore 메소드를 사용할 때.

<div dojoType="dojo.data.ItemFileReadStore" jsId="store" url="/child/index/"></div> // grid store 

<div dojoType="dojo.data.ItemFileReadStore" jsId="parentStore" url="/parent/index/"></div> // combo box store 

// 콤보 상자

<input dojoType="dijit.form.ComboBox" value="Select" width="auto" store="parentStore" searchAttr="name" name="parent" id="parent" onchange="displayChildren()"> 

// 내 GRID

<table dojoType="dojox.grid.DataGrid" jsId="grid" store="store" id="display_grid" 
    query="{ child_id: '*' }" rowsPerPage="2" clientSort="true" 
    singleClickEdit="false" style="width: 90%; height: 400px;" 
    rowSelector="20px" selectionMode="multiple"> 
    <thead> 
     <tr> 
      <th field="child_id" name="ID" width="auto" editable="false" 
       hidden="true">Text</th> 
      <th field="parent_id" name="Parent" width="auto" 
       editable="false" hidden="true">Text</th> 
      <th field="child_name" name="child" width="300px" editable="false">Text</th> 
      <th field="created" name="Created Date" width="200px" 
       editable="false" cellType='dojox.grid.cells.DateTextBox' 
       datePattern='dd-MMM-yyyy'></th> 
      <th field="last_updated" name="Updated Date" width="200px" 
       editable="false" cellType='dojox.grid.cells.DateTextBox' 
       datePattern='dd-MMM-yyyy'></th> 
      <th field="child_id" name="Edit/Update" formatter="fmtEdit"></th> 
     </tr> 
    </thead> 
</table> 

// onchange를 전에서 새 데이터 그리드를 다시로드하려고하는 부모 콤보 상자의 방법 서버.

function displayChildren() { 
       var selected = dijit.byId("parent").attr("value"); 
       var grid = dojo.byId('display_grid'); 
       var Url = "/childsku/index/parent/" + selected; 
       grid.setStore(new dojo.data.ItemFileReadStore({ url: Url })); 
      } 

그러나 내 눈금을 새 내용으로 업데이트하지 않습니다. 사용자가 콤보 상자 값을 변경할 때마다 그리드를 새로 고치는 방법을 모르겠습니다.

는 아무도 내가 ItemFileReadStore 및 ItemFileWrireStore 모두를위한 솔루션을 얻을 경우

내가 기쁠 ... 내가이 문제를 해결하는 데 도움이 수 없습니다.

감사

주권은 ..

답변

3

난 당신이 ()가 단계를 가져올 수없는 것 같아요. 다음은 이벤트 처리기를 코딩하는 방법입니다.

function displayChildren() { 
    var selected = dijit.byId("parent").attr("value"); 
    var store = new dojo.data.ItemFileWriteStore({ // Read or Write, no difference 
     url: "/childsku/index/parent/" + selected 
    }); 
    // Fetch the grid with the data 
    store.fetch({ 
     query : {}, 
     onComplete : function(items, request) { 
      var grid = dojo.byId('display_grid'); 
      if (grid.selection !== null) { 
       grid.selection.clear(); 
      } 
      grid.setStore(store); 
     }, 
     error: function(message, ioArgs) { alert(message+"\nurl: "+ioArgs.url); } 
    }); 
} 
관련 문제