0

我需要在一个复杂的 RIA 应用程序中即时使用出色的 Dojo DataGrids。问题是我不能使用元素 ID。如何在 javascript 中创建 DataGrids,然后将其插入页面?这是我目前正在做的事情:

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

这会构建表格,但您看不到它,也没有数据。

4

1 回答 1

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"}
     ]
}); 
于 2012-04-13T10:33:33.877 回答