2005-12-14 – Important Update:
There has been a change in how the submitted filter values get handled between SP47 and SP54 (on WebAS 6.20), that’s why there is a problem like Marcus mentioned in his comment. I posted one quick way to find a solution in the BSP forum: TableView Filter DropDown
Watch this thread for further updates on this topic.
This one lay around unfinished for quite a while now, but as I got asked a question lately where I would have liked to pointed to my weblog, it was about time to get it done.
Before we start with the main example, pay attention to these weblogs, they give you the basics for MVC structure and tableview iterators, which I’m gonna use here. I only want to focus on the filter part, so please consult these references for additional info:
Start with a tableview with filter …
… and then add a DropDown in the Filter Row
-selection = ‘‘.<br /> append filter lines:-name = ‘‘.<br /> <wa>-value = ‘‘.
That’s it, dropdown implemented – and hopefully working as well 🙂
Try it with some tables of your own, with less different values (that occur multiple times), play around a bit.
Use DropDown for iterator-manipulated column
For the second part of this weblog – maybe the language ISO code is not what you want in your tableview. And because you read some other weblogs (I hope you did) you use a tableview iterator to change the displayed text for your column. Replacing the code with the corresponding text from table T002T makes your data much more user-friendly.
METHOD if_htmlb_tableview_iterator~render_cell_start .
DATA: textview TYPE REF TO cl_htmlb_textview,
lv_language type string.
select sptxt from t002t
where spras = ‘E’
and sprsl = row_data_ref->spras.
textview = cl_htmlb_textview=>factory(
id = p_cell_id
text = lv_language ).
p_replacement_bee = textview.
But you also have to alter the part for your filter dropdown generation, otherwise you will still have the code values in the dropdown – which is not what you want.
Remember that (automatic) tableview functions like sort and filter can only work with data that is present in the table. If you are using an iterator to change the displayed content, you might run into problems, as your filter is not working as it is supposed to anymore.
By providing a filter dropdown you not only offer a more convenient way to use the filter, but you can also take care of any iterator-made display changes – this way the user will not get tempted to enter filter values that actually won’t work.