简体   繁体   English

我可以在ExtJS的网格面板单元格上设置多选功能吗?

[英]Can I set multi-on-select on grid panel cells in ExtJS?

Can I set multi-on-select on grid panel cells? 我可以在网格面板单元格上设置多选功能吗?

Hey guys, I'm fairly new to ExtJS and I was wondering if there is a way to multi-on-select grid CELLS or give the illusion of multi-on-select. 大家好,我是ExtJS的新手,我想知道是否有办法选择多选网格CELLS或给人一种多选错觉。 By "illusion" I mean to change the CSS of the individual cell dynamically on click so that it looks like it has remained toggled. 所谓“错觉”,是指在单击时动态更改单个单元格的CSS,以使其看起来像已切换。

The following is code to my Grid window Code: 以下是我的“网格”窗口代码的代码:

Ext.create ('Ext.window.Window' , {    title: this.id,
    width: 500 ,
    closeAction: 'hide',
    height: 500 ,
    modal: true,
    centered: true,
    items: [{
        xtype: 'gridpanel',
        sortable: false,
        allowDeselect: true,
        columnLines: true,
        header: false,
        sortableColumns: false,
        border: false,
        columns: [{
            xtype: 'gridcolumn',
            dataIndex: 'ID',
            text: 'ID',
            flex: 2
        },
        {
            xtype: 'gridcolumn',
            dataIndex: 'Title',
            text: 'Title',
            flex: 3
        },
        {
            xtype: 'gridcolumn',
            dataIndex: 'Beginner',
            text: 'Beginner',
            flex: 5
        },
        {
            xtype: 'gridcolumn',
            dataIndex: 'Intermediate',
            text: 'Intermediate',
            flex: 5
        },
        {
            xtype: 'gridcolumn',
            dataIndex: 'Advanced',
            text: 'Advanced',
            flex: 5
        }],
        // One header just for show. There's no data,
        store: Ext.getStore('disciplinesStore')
    }]
    selModel: Ext.create('Ext.selection.CellModel', {
            allowDeselect: true,
            listeners: {
            select: {
                  fn: me.onCellModelSelect,
                  scope: me
                    }
              }
        })
}).show ();

And then 接着

onCellModelSelect: function(cellmodel, record, row, column, eOpts) {

        if(column === 2){
            stuff = 'Beginner';
        }else if(column === 3){
            stuff= 'Intermediate';
        }else if(column === 4){
            stuff = 'Advanced';
        }
        Ext.Msg.alert('asd',record.get(stuff));
    }

I realized an alternate way of solving this; 我意识到了另一种解决方法。

Instead of applying a cell selector which doesnt allow mode: 'MULTI' , divide each of the columns into individual tables and apply a row selector or check box selector to them and set that to MULTI. 而不是应用不允许mode: 'MULTI'的单元格选择器mode: 'MULTI' ,将每一列划分为单独的表,然后对它们应用行选择器或复选框选择器,并将其设置为MULTI。 Works like a charm. 奇迹般有效。

As a reference for others with the same problem, it now successfully looks like this 作为其他有相同问题的参考,它现在看起来像这样

在此处输入图片说明

The code of the Beginner, Intermediate and Advanced columns was replace by individual tables with a row selector function as follows 初级,中级和高级列的代码已被具有行选择器功能的单个表替换,如下所示

{
 xtype: 'gridpanel',
 flex: 2.5,
 autoRender: false,
 id: 'thegrid',
 style: 'white-space:normal',
 width: 723,
 header: false,
 title: 'My Grid Panel',
 allowDeselect: true,
 columnLines: true,
 sortableColumns: false,
 store: 'disciplinesStore',
 columns: [
     {
          xtype: 'gridcolumn',
          dataIndex: 'Beginner',
          text: 'Beginner',
          flex: 5
      }
           ],
           selModel: Ext.create('Ext.selection.RowModel', {
           allowDeselect: true,
           mode: 'SIMPLE',
           listeners: {
               deselect: {
                     fn: me.onRowModelDeselect,
                     scope: me
                     },
           selectionchange: {
                     fn: me.onRowModelSelectionChange,
                     scope: me
                     }
               }
         })
   }

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM