基于 ExtJS 4.1 实现 TreeGrid 数据增删改查

介绍如何使用 ExtJS 4.1 框架实现 TreeGrid 组件的数据增删改查 (CRUD) 功能。

1. 单元格编辑

通过以下方法可以设置 TreeGrid 单元格为编辑状态:

  • selcell(arow, acol):通过指定行(arow)和列(acol)索引启动编辑插件。
selcell: function(arow, acol) {
  this.editingPlugin.startEditByPosition({
    row: arow,
    column: acol
  });
}, 
  • selcell2(node, acol):通过指定节点(node)和列(acol)索引启动编辑插件。
selcell2: function(node, acol) {
  this.editingPlugin.startEdit(node, acol);
} 

2. 客户端状态更新

使用 commit 方法将 TreeGrid 更新为已保存状态:

commit: function(records) {
  Ext.Array.each(records, function(record) {
    record.updateInfo();
    record.commit();
  });
}

3. 节点刷新

使用 store.load 方法刷新 TreeGrid 中指定的节点:

store.load({
  node: node
});

4. 数据交互

  • insertdb(newrecords): 使用 Ajax 异步提交新增数据。

  • updatedb(updaterecords): 使用 Ajax 异步提交修改数据。

通过以上方法,可以实现 ExtJS 4.1 TreeGrid 组件的 CRUD 功能,方便用户对树形结构数据进行管理和操作。

7z 文件大小:4.28KB