开发者

In ExtJS 4.0, how to config several "feature"s in a grid and toggle among them?

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: '开发者_如何学Pythongroupingsummary',
  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]
});  


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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜