简体   繁体   中英

Wicket custom filter without dropdown table

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): 示例数据表可单击按钮

Could someone point me in the right direction?

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.

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 .

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);
}

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM