[英]Get Grid Feature by ftype, not id
I am writing a generic class which is derived from ExtJS grid, and I have to check that the grouping
feature is used during toolbar instantiation (if grouping
is enabled, I want to auto-add two buttons to collapse/expand all groups). 我正在编写一个从ExtJS网格派生的通用类,并且我必须检查工具栏实例化期间是否使用了
grouping
功能(如果启用了grouping
,我想自动添加两个按钮来折叠/展开所有组)。
var groupingFeature = me.getView().getFeature("grouping")
if(groupingFeature && me.store.grouper) {
me.toolbar.insert(0,[{
iconCls:'icon-plus',
handler:function() {
groupingFeature.expandAll();
}
},{
iconCls:'icon-minus',
handler:function() {
groupingFeature.collapseAll();
}
}]);
}
But the grouping feature is not selected, because getFeature
only works with ID (and I can't rely that a special id is added to every grouping feature). 但是未选择分组功能,因为
getFeature
仅适用于ID(并且我不能依靠在每个分组功能中都添加了特殊的ID)。
Is there a way to get the feature by ftype
? 有没有办法通过
ftype
获取功能?
You could search by ftype
in a loop over the features array or use the private Method findFeature
of the Ext.grid.View, which is doing this. 您可以在功能数组中循环搜索
ftype
或使用Ext.grid.View的私有方法findFeature
来执行此操作。 By the extjs documentation : 通过extjs 文档 :
Finds a features by ftype in the features array
在功能数组中按ftype查找功能
So using this function, you should get you the required information. 因此,使用此功能,您应该会获得所需的信息。
var view = me.getView();
var groupingFeature = view.findFeature("grouping");
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.