2011-02-23 9 views
0

안녕하세요, Yahoo lib-grid를 연구하려고합니다. 그리드를 표시하는 단추를 만들었습니다. 하지만 버튼을 N 번 클릭하면 N 개의 그리드로 표시됩니다. 난 단지 하나의 그리드를 표시하고 버튼을 클릭 한 후 다시 서버에서 데이터를 얻을 것이다 싶어요. 내 코드는 아래와 같습니다 : 도와주세요., 고마워요.YUI-grid : 데이터로드

YUI({ filter: 'raw' }).use("jsonp", "node",function (Y) { 

    function handleJSONP(response) { 
    // Y.one("#out").setContent(Y.Lang.sub(template, response.user)); 
    YUI().use("datatable-base", function(Y) { 
     var cols = [ 
      { key: "id", label: "Transaction No", abbr: "id"}, 
      { key: "userName", label: "User Name", abbr: "userName"}, 
      { key: "storeName", label: "StoreName", abbr: "storeName"} 
     ], 
     data = response.Root, 
     dt = new Y.DataTable.Base({ 
      columnset: cols, 
      recordset: data, 
      summary: "Price sheet for inventory parts", 
      caption: "These columns have labels and abbrs" 
     }).render("#example"); 
    }); 
} 

    Y.one("#demo_btn").on("click", function (e) { 
     var url = "server.jsp"+ "?callback={callback}"; 
     Y.jsonp(url, handleJSONP); 
    }); 

}); 

답변

0

JSONP를 통해 데이터를 검색하려면 DataSource 유틸리티를 사용해야합니다. 이것은 당신이 다음 사항에 대한 참조를

dt.datasource.load();

같은 것을 통해 문서의 데이터를 다시로드 할 수 있습니다 : DataTable + DataSource.Get + JSON Data

  1. 처리기가 이미 테이블을 만든 경우 확인해야합니다.

var dt; if (dt === null) { dt = new Y.DataTable.Base // etc. }