【问题标题】:DataGrid formatter callback doesn't work as expectedDataGrid 格式化程序回调无法按预期工作
【发布时间】:2011-08-13 06:56:16
【问题描述】:

我正在为我的 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。知道为什么会这样吗?

【问题讨论】:

    标签: javascript datagrid dojo


    【解决方案1】:

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

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2012-10-14
      • 2022-09-29
      • 2013-05-01
      • 2015-10-17
      • 1970-01-01
      • 2022-08-17
      相关资源
      最近更新 更多