2012-04-13 98 views
0

我需要在一个复杂的RIA应用程序中动态地完善Dojo DataGrid。问题是我不能使用元素ID。我如何在javascript中创建DataGrid并将其插入到页面中?这是我目前正在做的:dojo dynamic datagrid without element id

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