首页 > 解决方案 > 无法检索网格中的选定记录

问题描述

我正在使用 ExtJS 7.1 并创建了一个网格面板。我无法使用代码 Ext.getCmp("tempGrid").getSelectionModel().getSelection() 检索选定的行,这行代码始终返回长度为 0。

Ext.getCmp("tempGrid").getSelectionModel().hasSelection(),这行代码总是返回false。

我不知道出了什么问题,想寻求建议或建议。谢谢

我有一个选项卡面板作为主面板(mainPanel),然后我附加/链接了另一个面板(称为 tempGrid) 在 tempGrid 内,我将放置网格,这是网格配置

items: {
  xtype: 'gridpanel',
  id: 'tempGrid',
  header: false,
  forceFit: true,
  store: 'AStore',
  columns: [{
      xtype: 'gridcolumn',
      dataIndex: 'colA',
      text: 'A Column',
      filter: {
        type: 'string'
      }
    },
    {
      xtype: 'gridcolumn',
      dataIndex: 'colB',
      text: 'B Column',
      filter: {
        type: 'string'
      }
    }
  ],
  plugins: [{
    xtype: gridfilters ''
  }],
  dockedItems: [{
    xtype: 'pagingtoolbar',
    dock: 'bottom',
    displayInfo: true,
    inputItemWidth: 80,
    store: 'AStore'
  }]
}

标签: extjssencha-architectextjs7

解决方案


您的网格配置示例中的网格具有 id APanel。你必须打电话

Ext.getCmp("APanel").getSelectionModel().getSelection()

获取选定的记录。我想tempGrid是另一个你的网格


推荐阅读