EXTJS 3.3.3 网格

标签 extjs

我正在使用 EXTJS 网格开发带有分页的复选框网格列表。我需要在执行页面导航时记住所选记录。

详细信息: 1) 转至第 1 页并选择第 1,2 和 3 行。 2)现在导航到页面:2 3)返回页面:1 4) 已选择的第 1,2 和 3 行应显示为已选择

grid中有没有处理这种功能的api?

提前致谢。

最佳答案

感谢您的回复。我通过实现网格插件来实现我的设计。该插件看起来像,

Ext.namespace('Ext.ux.plugins');

Ext.ux.plugins.CheckBoxMemory = Ext.extend(Object,
{
   constructor: function(config)
   {
      if (!config)
         config = {};

      this.prefix = 'id_';
      this.items = {};
      this.idProperty = config.idProperty || 'id';
   },

   init: function(grid)
   {
      this.view = grid.getView()
      this.store = grid.getStore();
      this.sm = grid.getSelectionModel();
      this.sm.on('rowselect', this.onSelect, this);
      this.sm.on('rowdeselect', this.onDeselect, this);
      this.store.on('clear', this.onClear, this);
      this.view.on('refresh', this.restoreState, this);
   },

   onSelect: function(sm, idx, rec)
   {
      this.items[this.getId(rec)] = true;
   },

   onDeselect: function(sm, idx, rec)
   {
      delete this.items[this.getId(rec)];
   },

   restoreState: function()
   {
      var i = 0;
      var sel = [];
      this.store.each(function(rec)
      {
         var id = this.getId(rec);
         if (this.items[id] === true)
            sel.push(i);

         ++i;
      }, this);
      if (sel.length > 0)
         this.sm.selectRows(sel);
   },

   onClear: function()
   {
      var sel = [];
      this.items = {};
   },

   getId: function(rec)
   {
      return rec.get(this.idProperty);
   }
});

这个插件是从 gird 调用的,

Ext.grid.Gridpanel({
store: 'someStore',
plugins: [new Ext.ux.plugins.CheckBoxMemory({idProperty: "recordID"})]

});

希望这对某人有所帮助。

关于EXTJS 3.3.3 网格,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/8940688/

相关文章:

extjs - 谁能解释一下 Sencha Touch Controller 如何与相关 View 结合

extjs - 如何创建向 Controller 注册的模型的新实例?

本地数据的 Extjs 网格面板性能问题

javascript - 如何在 Ext JS 中使用当前值进行模板调节?

javascript - ExtJS Tabpanel 和 JSON 数据未加载?

Extjs 6 - 自定义主题包错误

javascript - Siesta:组件查询断言不起作用

javascript - appendChild树节点不展开

JavaScript "me"= "this",为什么?

javascript - 最好的 Sencha 指南?