如何在Dojo dgrid中创建列?

时间:2014-05-30 16:00:13

标签: dojo dgrid

如何在dgrid中插入新列?

我的代码:

window.grid = new DataGrid({bufferRows: Infinity}, "gridResultsDiv");

for (var i = 0; i < layoutFields.length; i++) {
  var newColumn = [{ field: layoutFields[i].field, name: layoutFields[i].name }];

  grid.set("columns", newColumn);
}

但是我的数组layoutFields的最后一列仍然存在。 我做错了什么?

1 个答案:

答案 0 :(得分:0)

我编写了这段代码,现在显示了所有列:

            grid = new (declare([DataGrid, Selection]))({
                bufferRows: Infinity,
                columns: layoutFields, // layoutFields is my array with fields and labels.
                selectionMode: "single"
            }, "gridRresultsDiv");

            var memStore = new Memory({ data: data });
            grid.set("store", memStore);
            grid.startup();

TKS