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;
}
});
這建立了表,但你看不到它,並且沒有數據。