Skip to Content

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:

BSP – a Developer’s Journal: Part XI – Table View Iterators

BSP Programming: HTMLB TableView Iterator

BSP / HowTo: Exploring BSP Development with MVC</p>

Start with a tableview with filter …

image

… and then add a DropDown in the Filter Row

-selection  = ‘‘.<br /> append filter lines:-name  = ‘‘.<br />  <wa>-value = ‘‘.

image

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.

CASE p_column_key.

* –


WHEN ‘LAISO’.

select sptxt from t002t
into lv_language
where spras = ‘E’
and sprsl = row_data_ref->spras.
endselect.

textview = cl_htmlb_textview=>factory(
id = p_cell_id
text = lv_language ).
p_replacement_bee = textview.

* –


ENDCASE.

ENDMETHOD.

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.

!https://weblogs.sdn.sap.com/weblogs/images/22606/Iterator-Filter-Dropdown-04.jpg|height=131|alt=image|width=183|src=https://weblogs.sdn.sap.com/weblogs/images/22606/Iterator-Filter-Dropdown-04.jpg|border=0!image

Summary

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.

To report this post you need to login first.

4 Comments

You must be Logged on to comment or reply to a post.

  1. Former Member
    Good Job! Well done Max, I think you managed to present what seems to be a complicated problem in a nice and easy way.

    Now I have a easy weblog to point people to as well 🙂

    Craig

    (0) 
    1. Thanks for this posting!
      I just came across this behaviour in the process of checking my applications when upgrading from SP 47 to SP 54. And your comment here reminded me of this weblog.

      I don’t know how soon I will be able to adjust the solution from this weblog (haven’t had time to find the cause for the problem), but in the meantime please post your problem in the BSP forum, and mention you are using the code from this weblog. If someone else has already dealt with that, hopefully we will get a quick answer, otherwise I will use the forum thread to announce anything I find out about it.

      (0) 

Leave a Reply