0

I want to create a custom filter for my DataTable. I would like to create a button that, when clicked on it, changes the table its data. I know about the ChoiceFilteredPropertyColumn that wicket has to offer but this is, according to my understanding of it, a dropdown filter.

I am trying to achieve something like the following picture (Pancakes is the clickable button): example data table clickable button

Could someone point me in the right direction?

Bram
  • 4,533
  • 6
  • 29
  • 41

3 Answers3

1

Well... the superclass of ChoiceFilteredPropertyColumn is FilteredPropertyColumn which might do the trick. Otherwise you could always implement your own Column that implements IFilteredColumn the way you like it.

Nicktar
  • 5,548
  • 1
  • 28
  • 43
1

Look at how the implemented `DataTable' here: http://www.packtpub.com/sites/default/files/1605OS-Chapter-5-Displaying-Data-Using-DataTable.pdf

Then you could implement your dropdown button filter like you want it and filter with the selected value the DataTable.

Robert Niestroj
  • 15,299
  • 14
  • 76
  • 119
0

I solved this question by creating a custom filter (just a panel with some markup) and return it in the getFilter method of a custom FilteredPropertyColumn.

FilteredPropertyColumn: http://wicket.apache.org/apidocs/1.4/org/apache/wicket/extensions/markup/html/repeater/data/table/filter/FilteredPropertyColumn.html

getFilter method: http://wicket.apache.org/apidocs/1.4/org/apache/wicket/extensions/markup/html/repeater/data/table/filter/IFilteredColumn.html#getFilter%28java.lang.String,%20org.apache.wicket.extensions.markup.html.repeater.data.table.filter.FilterForm%29

ButtonFilter class:

public class ButtonFilter extends Panel {
     ...
}

In custom FilteredPropertyColumn class:

@Override
public Component getFilter(String componentId, FilterForm<?> form) {
    return new ButtonFilter<Y>(componentId, getFilterModel(form), filterChoices);
}
Bram
  • 4,533
  • 6
  • 29
  • 41