【问题标题】:Extjs 6.5.3 Binding hidden property of widgetcolumn from record valuesExtjs 6.5.3 从记录值绑定小部件列的隐藏属性
【发布时间】:2018-07-11 13:04:12
【问题描述】:

我想使用我的记录的属性显示/隐藏网格的小部件列。

我试图通过绑定我的值来做到这一点:

{
    xtype: 'grid',
    bind: {
        store: 'ActionList'
    },
    border: true,
    flex: 2,
    name: 'actionList',
    title: this.titleActionGrid,
    columns: [{
        xtype: 'widgetcolumn',
        height: 50,
        width: 65,
        widget: {
            xtype: 'button',
            text: '{sActionTitle}',
            scale: 'large',
            height: 45,
            width: 45,
            margin: 5
        },
        bind: {
            hidden: '{bIsHidden}'
        }
    }]
}

这不起作用,所以我在互联网上搜索并找到了这个小提琴:https://fiddle.sencha.com/#view/editor&fiddle/22rl

所以我用这部分代码试了一下:

cell: {
    tools: {
        up: {
            bind: {
                hidden: '{record.bIsHidden}'
            }
        }
    }
}

但这并没有奏效,事实上小提琴是现代的,而我的代码是经典的..

我没有找到其他任何东西,这就是我在这里的原因,恳求任何人帮助我;)

在此先感谢您。

ExtJS 经典 6.5.3

【问题讨论】:

    标签: extjs binding grid extjs6


    【解决方案1】:

    你可以这样绑定它:

    Ext.create('Ext.grid.Panel', {
         renderTo: Ext.getBody(),
         store: store,
         border: true,
         flex: 2,
         name: 'actionList',
         title: this.titleActionGrid,
         columns: [{
                 dataIndex: 'id',
             },
             {
                 xtype: 'widgetcolumn',
                 height: 50,
                 width: 165,
                 dataIndex: 'hide',
                 widget: {
                     bind: {
                         text: '{record.id}',
                         hidden: '{record.hide}'
                     },
                     xtype: 'button',
                     scale: 'large',
                     height: 45,
                     width: 155,
                     margin: 5
                 }
             }
         ]
     });
    

    【讨论】:

      【解决方案2】:

      您可以使用rowViewModel 按记录绑定小部件列。 Fiddle:

      Ext.application({
          name: 'Fiddle',
      
          launch: function () {
              new Ext.grid.Panel({
                  renderTo: document.body,
                  viewModel: {
                      data: {
                          actionTitle: 'Remove'
                      }
                  },
                  store: {
                      data: [{
                          name: 'A',
                          hidden: false
                      }, {
                          name: 'B',
                          hidden: true
                      }]
                  },
                  rowViewModel: true,
                  columns: [{
                      dataIndex: 'name',
                      text: 'Name'
                  }, {
                      xtype: 'widgetcolumn',
                      widget: {
                          xtype: 'button',
                          bind: {
                              text: '{actionTitle}',
                              hidden: '{record.hidden}'
                          },
                          margin: 5
                      },
                  }]
              });
          }
      });
      

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2011-12-24
        • 1970-01-01
        • 2013-10-17
        • 1970-01-01
        • 2012-08-29
        相关资源
        最近更新 更多