即使定义了Dgrid子行也不会出现

时间:2017-04-12 14:44:20

标签: dojo dgrid

this.grid = new CustomGrid({
                    collection: this.store,
                    subRows: [
                        [
                            { field: 'first', label: 'First', rowSpan: 2 },
                            { field: 'last', label: 'Last', rowSpan: 2 },
                            { field: 'bats', label: 'Bats', rowSpan: 2 },
                            { field: 'throws', label: 'Throws', rowSpan: 2 },
                            { field: 'totalG', label: 'G' },
                            { field: 'totalAB', label: 'AB' },
                            { field: 'totalR', label: 'R' },
                            { field: 'totalRBI', label: 'RBI' },
                            { field: 'totalBB', label: 'BB' },
                            { field: 'totalK', label: 'K' }
                        ],
                        [
                            { field: 'totalGAB', label: 'Games as Batter', colSpan: 2 },
                            { field: 'totalH', label: 'H' },
                            { field: 'total2B', label: '2B' },
                            { field: 'total3B', label: '3B' },
                            { field: 'totalHR', label: 'HR' }
                        ]
                    ],
                    showHeader: true,
                    className: 'dgrid-autoheight',
                    showFooter: false,
                    selectionMode: "none",
                    loadingMessage: "Loading form...",
                    noDataMessage: "No Skill in this form"

         });

我正在使用上面的代码创建一个dgrid。我已经在我的基础html中加载了dojo.css,claro.css和dgrid.css。但由于某种原因,子行不会在我的屏幕上呈现。

1 个答案:

答案 0 :(得分:0)

我可能错了,但我很确定这是一个愚蠢的错误,现在是:

collection: this.store

在该上下文中,this引用CustomGrid对象。您可能已经在之前加载了存储,并将其存储在另一个上下文(实例化网格)的属性中。如果您没有加载商店,则无法呈现数据,因为它不适用于网格。

所以,基本上,简单的解决方法是:

var self = this;
this.grid = new CustomGrid({
    collection: self.store
    // all other grid properties
});

希望它有所帮助。