on 12-13-2005 12:50 PM
Hello guys,
I justed tested the code from Maximilians Weblog: <a href="/people/sap.user72/blog/2005/05/05/bsphowto-filter-using-dropdown-in-tableview:///people/sap.user72/blog/2005/05/05/bsphowto-filter-using-dropdown-in-tableview about filtering a table with a dropdown.
But i have following problem:
I want to save the selected filter from my dropdown-filter-box.
But when i debuged my program the status in <filters> is always this '*' placeholder.
How can I cause that the same filter criteria is set when i change my pages internal (want to save the selected filter in my model )?
I already contacted the weblog itself but Maximilian didn't have an answer.
Can somebody help me?
Kind regards
Marcus
How can I list down on second dropdown for example cities of a country under an id number selected on the first dropdown base on the filtered table in SAP Analytics Application
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Marcus,
thx for posting this here as well. I will work on this problem in the next few days, keep your eyes peeled for updates here.
Max
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Ok, instead of digging into the problem too deep I just tried to find a workaround real quick. Here is what I came up with.
Change the part that sets the selection value when creating the filter:
* define a pre-selection
<filter>-selection = '*'.
Instead of just setting this value we now check if a value for this filter dropdown has been submitted:
data: lv_selection type string.
...
...
* set the selection value
clear lv_selection.
lv_selection = request->get_form_field( name = 'your_tableview_id-filter_XXX' ).
if lv_selection is not initial.
<filter>-selection = lv_selection.
else.
<filter>-selection = '*'.
endif.
Only if there is no filter value submitted we will use the '*' as pre-selection.
This is just a quick fix to get around this problem, not a big solution. Especially because you have to check for submitted values manually, and you have to replace the 'XXX' with the column number in your tableview, so changes in the tableview would require adaption of this code.
But, for the moment it works. I guess there have been changes in when the submitted filter values get caught by the model binding for the tableview - as I mentioned I didn't have time to go into more detail. Don't know if these changes were intended or not, if this behaviour will change with a future SP.
For now the filter is working again, hope you can live with this solution
Max
try the following.
data: event type ref to cl_htmlb_event .
event = cl_htmlb_manager=>get_event( request ).
if event->event_type eq cl_htmlb_event_tableview=>CO_FILTER .
data: tv type ref to cl_htmlb_tableview.
tv ?= cl_htmlb_manager=>get_data(
request = runtime->server->request
name = 'tableView'
id = 'test' ).
if tv is not initial.
data: tv_data type ref to cl_htmlb_event_tableview.
tv_data = tv->data.
now use
tv_data->GET_ROW_FILTER_VALUE to get the filter value and store it in a model variable.
and in you iterator where you set the default to * check whether the model variable is initial. if initial leave it to * else set it to the value in the model variable.
Hope this is clear.
Regards
Raja
Ok lets go:
HTMLB CODE FOR TABLEVIEW:
<htmlb:tableView id = "lo51"
rowCount = "25"
table = "<%= model->LO51 %>"
filter = "SERVER"
sort = "SERVER"
selectionMode = "SINGLESELECT"
keyColumn = "IDCUSTOMER"
onRowSelection = "myRowSelectLO51"
visibleRowCount = "10"
selectedRowKey="<%= model->SELECTED_KEY_OVER %>"
iterator = "<%= tv_iterator2 %>"
columnFilters = "<%=model->FILTER_OVERVIEW%>"/>
Creation of the filter:
<% data: filters type tableviewFilterTab,
count TYPE CRMT_BUS_REGIO_TEXT,
lv_selection type string.
field-symbols: <filter> like line of filters,
<wa> type IHTTPNVP2.
append initial line to filters assigning <filter>.
<filter>-columnName = 'COUNTRY'.
If model->ANALYSEIDCUSTOMER IS INITIAL.
clear lv_selection.
lv_selection = request->get_form_field( name = 'lo51-filter_2' ).
if lv_selection is not initial.
<filter>-selection = lv_selection.
else.
<filter>-selection = 'Switzerland'.
endif.
Else.
<filter>-selection = '*'.
EndIf.
append initial line to
<filter>-dropdownlistbox_table assigning <wa>.
<wa>-name = '*'.
<wa>-value = '*'.
Select COUNTRY from /SIE/AD_ZAVXLO17
INTO count
ORDER BY COUNTRY ASCENDING.
append initial line to <filter>-dropdownlistbox_table assigning <wa>.
<wa>-name = count.
<wa>-value = count.
ENDSELECT.
sort <filter>-dropdownlistbox_table by value.
model->FILTER_OVERVIEW = filters.
So the ABAP-Code above is in the view! But i think it has no preference if it is in do_handle_event or in the view.
Marcus
Hi Marcus,
messing around with tableview filters can be quiet a nice task...
Have you been able to solve your problem in the meantime?
Two things that came to my mind while reading your thread:
1.) I assume the code from your view is the other way round? I mean, you first change the model->filters and then render the tableview? Rendering the tableview first and then changing the filters might have no effect.
2.) Generally I've had some trouble changing filters, too. I've been able to implement what I need by playing around with the form_fields in the DO_HANDLE_DATA.
I read the values there, store them in my internal table filters and manipulate them as needed.
I think there was a thread somewhere in the forums explaining that filter values are stored internal making it impossible to change them after some point in the processing (changing them has no effect thereafter). Can't remember exactly what and where it was.
Regards,
Alex
Hi back after a while, I have a small update on the filter issue:
I found out that when setting the selected value for the filter to a value that is not included in the filter table, the filter won't work. This was especially nasty to find out as I didn't look at my values exactly.
For a smaller tableview I played around with the filter, because it wouldn't work. I had a second one, almost totally exact the same filter - with only one difference, I set my selection to '*'.
Now the way the filter works internally the joker character is ok for actually filtering the table values, but because of some code lines in a loop the filter value that was used in the filter table was '*' instead of ''. And of course after realizing that when creating the filter, these values are strings, not joker characters, so '' does not equal '*'.
Found that out, did a few tests, came to the conclusion that setting a selection value for the filter is critical, do not set it to a value that is not present in your filter dropdowntable! (WebAS 620, SP54)
Maybe this is helpful, check your code if this applies.
Max
Hi Alex,
Is it in the context of the weblog discussed here?
<i><b>Is there a way to find out what colum_index a column has</b></i>
column index is the same order as they are shown on the screen.
first column 1, secnd column 2 , etc
is this what you are looking for or did i misunderstand your question.
Regards
Raja
did you try this method to get the filter row value
CL_HTMLB_MANAGER=>GET_FILTER_ROW_VALUE
Regards
Raja
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
87 | |
10 | |
10 | |
10 | |
7 | |
6 | |
6 | |
5 | |
5 | |
4 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.