Search code examples
javaeclipseswtnattable

Is there a way to disable the 'clear filter' icon in Nattable filter row when there is no filter string?


When I click on a filter cell and then move on to a different area in my view without entering a filter string, the 'clear filter' icon is displayed in the cell even when I haven't entered a string. As shown in the Nattable given below, the filter columns having the icon enabled do not have any filter strings entered. Is there a way to explicity disable this behavior in the FilterRowConfiguration?

Nattable

I found a similar behavior in the _6031_GlazedListsFilterExample for the first column in that example. However, the other columns in that example do not show the 'clear filter' icon as expected.

Pasting the contents of my FilterRowConfiguration

final DefaultIntegerDisplayConverter idc = new DefaultIntegerDisplayConverter();
final DefaultLongDisplayConverter ldc = new DefaultLongDisplayConverter();

                @Override
        public void configureRegistry(IConfigRegistry configRegistry)
        {
        for (int i = 0 ; i < propNames.size() ; i++)    
            {
                
                configRegistry.registerConfigAttribute(
                        FilterRowConfigAttributes.TEXT_MATCHING_MODE,
                        TextMatchingMode.REGULAR_EXPRESSION, DisplayMode.NORMAL,
                        FilterRowDataLayer.FILTER_ROW_COLUMN_LABEL_PREFIX + i);
                configRegistry.registerConfigAttribute(
                        CellConfigAttributes.DISPLAY_CONVERTER,
                        new LinkerMapFilterRowRegexConverter(), DisplayMode.NORMAL,
                        FilterRowDataLayer.FILTER_ROW_COLUMN_LABEL_PREFIX + i);

            }
            configRegistry.registerConfigAttribute(                                 // comparator
                    FilterRowConfigAttributes.FILTER_COMPARATOR,
                    Comparator.nullsLast(new DefaultComparator()), DisplayMode.NORMAL,
                    FilterRowDataLayer.FILTER_ROW_COLUMN_LABEL_PREFIX + propNames
                            .indexOf(ILinkerMapConstants.PROP_KEY_SYMBOL_SIZE));

            configRegistry.registerConfigAttribute(                                 // filter display converter
                    FilterRowConfigAttributes.FILTER_DISPLAY_CONVERTER, idc,
                    DisplayMode.NORMAL,
                    FilterRowDataLayer.FILTER_ROW_COLUMN_LABEL_PREFIX + propNames
                            .indexOf(ILinkerMapConstants.PROP_KEY_SYMBOL_SIZE));

            configRegistry.registerConfigAttribute(
                    FilterRowConfigAttributes.TEXT_MATCHING_MODE,
                    TextMatchingMode.REGULAR_EXPRESSION, DisplayMode.NORMAL,
                    FilterRowDataLayer.FILTER_ROW_COLUMN_LABEL_PREFIX + propNames
                            .indexOf(ILinkerMapConstants.PROP_KEY_SYMBOL_SIZE));
            
            

            configRegistry.registerConfigAttribute(                                     // comparator
                    FilterRowConfigAttributes.FILTER_COMPARATOR,
                    Comparator.nullsLast(new DefaultComparator()), DisplayMode.NORMAL,
                    FilterRowDataLayer.FILTER_ROW_COLUMN_LABEL_PREFIX + propNames
                            .indexOf(ILinkerMapConstants.PROP_KEY_SYMBOL_ADDRESS));
            
            configRegistry.registerConfigAttribute(                                      // filter display converter
                    FilterRowConfigAttributes.FILTER_DISPLAY_CONVERTER, ldc,
                    DisplayMode.NORMAL,
                    FilterRowDataLayer.FILTER_ROW_COLUMN_LABEL_PREFIX + propNames
                            .indexOf(ILinkerMapConstants.PROP_KEY_SYMBOL_ADDRESS));
            configRegistry.registerConfigAttribute(
                    FilterRowConfigAttributes.TEXT_MATCHING_MODE,
                    TextMatchingMode.REGULAR_EXPRESSION, DisplayMode.NORMAL,
                    FilterRowDataLayer.FILTER_ROW_COLUMN_LABEL_PREFIX + propNames
                            .indexOf(ILinkerMapConstants.PROP_KEY_SYMBOL_ADDRESS));

        }


Solution

  • You should double check if there is really no value in the backing data in the FilterRowDataProvider. Debug why the filter icon is displayed. Because it should only show up if a value is set in the backing data.