DataGrid格式化程序回调无法按预期工作

时间:2011-04-26 18:41:43

标签: javascript datagrid dojo

我正在为Dojo 1.5 DataGrid使用以下布局:

function getGridLayout() {
  return [{
    name: "Stylist",
    field: "stylist",
    width: "100px"
  },
  {
    name: "Service",
    field: "service",
    width: "200px"
  },
  {
    name: "Length",
    field: "length",
    width: "50px"
  },
  {
    name: " ",
    field: "remove",
    width: "30px",
    formatter: getRemoveFormatter
  }];
}

这是我的回调定义:

function getRemoveFormatter(item) {
  console.log(item);
}

以下是我创建DataGrid的方法:

dojo.ready(function() {
  var store = new dojo.data.ItemFileWriteStore({data:{items:[]}});
  window.grid = new dojox.grid.DataGrid({store: store, structure: getGridLayout()}, document.createElement("div"));
  dojo.byId("services_grid").appendChild(grid.domNode);
  grid.startup();
  observeAppointmentServiceAddClick(window.grid);
  getAppointmentItems();
});

出于某种原因,item始终为undefined。知道为什么会这样吗?

1 个答案:

答案 0 :(得分:0)

原因是,每当我添加一行时,我都不会为“删除”列定义任何内容,因此该单元格中的项目自然是未定义的。

相关问题