[英]How to configure NatTable FilterComboBox to have a different DataProvider for each column
In my NatTable I am using a ComboBoxFilterRowHeaderComposite similar to ExcelLikeFilterRowCustomTypesExample . 在我的NatTable中,我使用的是类似于ExcelLikeFilterRowCustomTypesExample的ComboBoxFilterRowHeaderComposite。 It works fairly well however the combo box filtering adds too many items in large tables to allow for easy filtering.
它运行得相当不错,但是组合框过滤在大表中添加了太多项目以便于过滤。 I am trying to fix this by only filling the combo with certain items, however;
我试图通过仅填充某些项目的组合来解决这个问题; in my table some columns are just for types or operations which have a limited amount of different values and I would like to add all options for those.
在我的表中,一些列只适用于具有有限数量的不同值的类型或操作,我想为这些添加所有选项。 While for other columns I'd like to only add root items.
而对于其他列,我只想添加根项。
To achieve this I think I need to modify the comboBoxDataProvider, however; 为实现这一点,我认为我需要修改comboBoxDataProvider; for the full effect that I want it would require a different dataprovider for some columns.
为了达到我想要的全部效果,需要为某些列提供不同的数据提供器。
Is this the correct approach? 这是正确的方法吗? And if so how would I go about doing this?
如果是这样,我将如何做到这一点?
This is how I am currently configuring my combo box composite: 这就是我目前正在配置组合框复合的方法:
ComboBoxFilterRowHeaderComposite<GroupedPerfRecord> filterRowHeaderLayer =
new ComboBoxFilterRowHeaderComposite<GroupedPerfRecord>(
bodyLayerStack.getFilterList(),
bodyLayerStack.getBodyDataLayer(),
bodyLayerStack.getSortedList(),
columnPropertyAccessor, columnHeaderLayer,
columnHeaderDataProvider, configRegistry, false);
final IComboBoxDataProvider comboBoxDataProvider = filterRowHeaderLayer.getComboBoxDataProvider();
filterRowHeaderLayer.addConfiguration(new ComboBoxFilterRowConfiguration() {
{
this.cellEditor = new FilterRowComboBoxCellEditor(comboBoxDataProvider, 5);
this.filterIconPainter = new ComboBoxFilterIconPainter(comboBoxDataProvider, GUIHelper.getImage("filter"), null);
}
});
With a default filter row that has combo boxes for single selection you would use different IComboBoxDataProvider
for each column. 使用具有单个选择组合框的默认过滤器行,您将为每列使用不同的
IComboBoxDataProvider
。 But you have chosen the ComboBoxFilterRowHeaderComposite
that has a different filtering mechanism in the back to support multi selection and handling of Select All similar to well-known spreadsheet applications. 但是您选择了后面具有不同过滤机制的
ComboBoxFilterRowHeaderComposite
,以支持多选和处理Select All,类似于众所周知的电子表格应用程序。 So there is no build-in mechanism that would allow to simply configure the desired behavior. 因此,没有内置机制可以简单地配置所需的行为。
But there is a constructor in the ComboBoxFilterRowHeaderComposite
that takes a FilterRowComboBoxDataProvider
as parameter. 但是
ComboBoxFilterRowHeaderComposite
中有一个构造函数,它将FilterRowComboBoxDataProvider
作为参数。 So you could provide your own implementation of a FilterRowComboBoxDataProvider
(maybe subclass the GlazedListsFilterRowComboBoxDataProvider
) and implement the desired behavior in getValue()
based on the column index. 因此,您可以提供自己的
FilterRowComboBoxDataProvider
实现(可能是GlazedListsFilterRowComboBoxDataProvider
子类),并根据列索引在getValue()
实现所需的行为。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.