如何通过点击网格ExtJS中的一个单元格来选择记录

问题描述 投票:0回答:1

我有一个问题,因为当我单击表格行时,它的单元格被选中。该行也被选中,但单元格更加可见。我想让它根本不选择单元格,只选择行。单元格获得

.x-grid-item-focused
类和行
.x-grid-item-selected
。最好将该行标记为与
.x-grid-item-focused

相同的颜色
afterlayout: panel => {
        panel.getEl().setStyle('z-index', controlConfig.get('zIndex'))
        panel.mon(panel.el, 'click', () => {

        })
      },
javascript css extjs
1个回答
0
投票

你可以尝试这样的事情:

afterlayout: panel => {
  panel.getEl().setStyle('z-index', controlConfig.get('zIndex'));

  panel.mon(panel.getView(), {
    beforecellclick: (view, cell, cellIndex, record, row, rowIndex, e) => {
      // Prevent the default cell selection behavior
      e.stopEvent();

      // Manually select the entire row
      panel.getSelectionModel().select(record);

      const maxZControl = app
        .get('selectedTab')
        .get('controls')
        .maxBy(x => x.get('controlConfig').get('zIndex'));

      let zIndex = 0;
      if (maxZControl !== '-Infinity') {
        zIndex =
          maxZControl !== control
            ? maxZControl.get('controlConfig').get('zIndex') + 1
            : maxZControl.get('controlConfig').get('zIndex');
      }

      controlConfig.set('zIndex', zIndex);
      control.save();
    }
  });
},

您可以使用ExtJS beforecellclick事件来防止单元格被选中并手动选择整行。

© www.soinside.com 2019 - 2024. All rights reserved.