2012-04-13 2 views
0

복잡한 RIA 애플리케이션에서 즉석 Dojo DataGrid를 사용해야합니다. 문제는 요소 ID를 사용할 수 없다는 것입니다. JavaScript로 DataGrid를 만들고 페이지에 삽입하려면 어떻게해야합니까? 현재 수행중인 작업은 다음과 같습니다.요소 id가없는 dojo 동적 DataGrid

Backbone.View.extend({ 
    name: 'checkout', 
    template: dojo.cache('plugins.patrons.views.templates', 'actions/checkout.html'), 
    el: $('<div>'), 
    store: new dojo.store.Memory({data: [{id: 1, "accession": '1000', "title": 'my book'}]}), 

    initialize: function(el, data) { this.el = el; this.data = data; }, 

    render: function() 
    { 
     dojo.parser.parse(this.el.empty().html(_.template(this.template, this.data, {variable: 'data'}))[0]); 
     var grid = new DataGrid({ 
      store: ObjectStore({objectStore: this.store}), 
      structure: [ 
       {name:"Accession Number", field:"accession", width: "200px"}, 
       {name:"Title", field:"title", width: "400px"} 
      ] 
     }); 
     $('.checkout.action .data-grid', this.el).append(grid.domNode); 
     grid.startup(); 
     return this; 
    } 
}); 

이 작업은 테이블을 작성하지만 볼 수없고 데이터가 없습니다.

답변

0

그리드에 명시적인 높이를 부여하십시오.

var grid = new DataGrid({ 
    height: 400px, 
    store: ObjectStore({objectStore: this.store}), 
    structure: [ 
      {name:"Accession Number", field:"accession", width: "200px"}, 
      {name:"Title", field:"title", width: "400px"} 
    ] 
});