在 ExtJS 4.0 中,如何在网格中配置多个“功能”并在它们之间切换?

发布于 2024-12-02 19:14:30 字数 1340 浏览 1 评论 0原文

var groupingFeature = Ext.create('Ext.grid.feature.Grouping'); 
Ext.create('Ext.grid.Panel', {
     // other options
     features: [groupingFeature]
}); 

我可以将新功能添加到 [groupingFeature] 数组中吗?我该怎么做呢?

如果有多个功能,我如何在它们之间切换?


现在我知道如何设置几个功能(但我不确定这种方式是否正确):

var groupingFeature = Ext.create('Ext.grid.feature.Grouping',{
  id: 'group',
  ftype: 'groupingsummary',
  groupHeaderTpl: '{name}',
  hideGroupedHeader: true,
  enableGroupingMenu: false
});
var abstractSummaryFeature = Ext.create('Ext.grid.feature.AbstractSummary',{
  id: 'summary',
  ftype: 'abstractsummary',
  hideGroupedHeader: false,
  enableGroupingMenu: true
});
Ext.create('Ext.grid.Panel', {
     // other options
      dockedItems: [{
          dock: 'top',
          xtype: 'toolbar',
          items: [{
              tooltip: 'Change the feature',
              text: 'Change',
              handler: function(){
                  var view = Ext.getCmp('sell_quote_item_grid').getView();
                  view.getFeature('group').disable();//someone says I can toggle in this way,
                  view.getFeature('summary').enable();//I tried but failed...
                  view.refresh();
              }
          }]
      }],
     features: [groupingFeature, abstractSummaryFeature]
});  
var groupingFeature = Ext.create('Ext.grid.feature.Grouping'); 
Ext.create('Ext.grid.Panel', {
     // other options
     features: [groupingFeature]
}); 

Can I add a new feature into the [groupingFeature] array? How can I do it?

And if there are several features, how can I toggle among them?


Now I know how to set several features (but I'm not sure wether this way is correct or not):

var groupingFeature = Ext.create('Ext.grid.feature.Grouping',{
  id: 'group',
  ftype: 'groupingsummary',
  groupHeaderTpl: '{name}',
  hideGroupedHeader: true,
  enableGroupingMenu: false
});
var abstractSummaryFeature = Ext.create('Ext.grid.feature.AbstractSummary',{
  id: 'summary',
  ftype: 'abstractsummary',
  hideGroupedHeader: false,
  enableGroupingMenu: true
});
Ext.create('Ext.grid.Panel', {
     // other options
      dockedItems: [{
          dock: 'top',
          xtype: 'toolbar',
          items: [{
              tooltip: 'Change the feature',
              text: 'Change',
              handler: function(){
                  var view = Ext.getCmp('sell_quote_item_grid').getView();
                  view.getFeature('group').disable();//someone says I can toggle in this way,
                  view.getFeature('summary').enable();//I tried but failed...
                  view.refresh();
              }
          }]
      }],
     features: [groupingFeature, abstractSummaryFeature]
});  

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

她如夕阳 2024-12-09 19:14:30

根据 TableChunker.js 中的这段代码,就像禁用您不想渲染的“功能”一样简单。然后刷新视图。

您可以通过调用 feature.disable() 来禁用某个功能,并通过调用 feature.enable() 来启用它,这似乎是错误的,我希望 feature.enable(enabled=true|false)

    for (; i < ln; i++) {
        if (!features[i].disabled) {
            features[i].mutateMetaRowTpl(metaRowTpl);
            Ext.apply(memberFns, features[i].getMetaRowTplFragments());
            Ext.apply(tplMemberFns, features[i].getFragmentTpl());
            Ext.apply(tableTplMemberFns, features[i].getTableFragments());
        }
    }

一个更困难的问题是如何获得groupingSummary 和 Summary 在同一个表中一起工作。这要困难得多。

Based on this code in TableChunker.js, it is as simple as disabling the "features" you don't want to render. and then refreshing the view.

You can disable a feature by calling feature.disable() and enable it by calling feature.enable() which seems wrong, I would expect feature.enable(enabled=true|false)

    for (; i < ln; i++) {
        if (!features[i].disabled) {
            features[i].mutateMetaRowTpl(metaRowTpl);
            Ext.apply(memberFns, features[i].getMetaRowTplFragments());
            Ext.apply(tplMemberFns, features[i].getFragmentTpl());
            Ext.apply(tableTplMemberFns, features[i].getTableFragments());
        }
    }

An even more difficult question is how do you get a groupingSummary and a Summary to work together in the SAME table. That is a good deal harder.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文