on 09-08-2010 11:54 AM
Hi ,
My requirement is to get the selected items of current view to the next view, i.e. for example we see in online shopping the selected item gets copied into a itemboxlist.
and requirement is also same, which method should i use to get only the selected item
in my example i used checkbox group and my problem is if i am selecting 2/10 items but its displaying me all 10 items in the next view.
Kindly can someone help me.
Thanks
Sankar
Hi,
Since you are using checkboxgroup ,I assume that you would have created a node of cardinality 0:n and a attribute under them of type string or int (which represents the text for checkbox).
The number of checkboxes equals the number of node elements.
And also , the selection of the checkboxes is determined by the multiple selection of the node .
So you can use GET_SELECTED_ELEMENTS( ) method of IF_WD_CONTEXT_NODE for the node to get all the selected checkboxes.
Now you can create the same context (that you used in previous view) and perform a GET_SELECTED_ELEMENTS to get selected checkboxes in second view.
Then you can call get_static_attributes() on the selected elements and display the texts of selected checkboxes in the second view.
Thanks,
Aditya.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi,
If you are navigating from one view to another view, use 2 diffterent context nodes. Form one view, get the selected values and fill the second node, which will be used in second view.
You can use 1 global node so that data will be available in both the nodes.In the INIT method of second view, get the selected values and bind to the local node.
Regards,
Manogna
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi,
You can use get_selected_elements( ) method of if_wd_context_node to get the selected elements.
Regards,
Manogna
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
we donot have any particular method foe this.
What you can do is set a flag in the context which indicates the items are selected.
In the next view use the same context and display only the selected elemets form the previous view
or u can use get_selected elemets of if_wd_context_node and display only those elemets in the next view.
For these approaches create a node in component controller and reuse the same in the 2 view mentioned.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
in that case, create a local node same as the global node
In the HANDLE<Inboundplugname> method move the selected elements to the loal node and use this node for display
For every inbound plug a method will be generated with the above namiong convention.
Check which inpound plug method is triggerd and place the code in that method
Regards,
Madhu
Edited by: madhu reddy on Sep 8, 2010 5:44 PM
Hi Sankar,
I believe, you are using views of the same component.
I would suggest you to use an attribute of table type in component controller where you could save the selected checkbox and retrieve in another view.
Regards
Anurag Chopra
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Sankar,
First you need to capture the information what all items are selected and you need to share this data between the two views.
So when you are on first view, you could use attribute at component controller level under attribute tab and not under context.
You could use context as well but i would not suggest you to use it.
attributes defined at component controller level will be the common data source shared between the two views.
Regards
Anurag Chopra
>So when you are on first view, you could use attribute at component controller level under attribute tab and not under context.
>You could use context as well but i would not suggest you to use it.
I'd differ from this suggestion, as I really don't like the practice of using component attributes for data transport - I find it makes it much harder to read the code and understand what is going on.
Instead the idea of having two context node, one which you fill from the selected elements of the other, is much more appealing, and would be, in my opinion, easier to understand if you had not dealt with the code previously.
DATA lo_nd_is_data TYPE REF TO if_wd_context_node.
DATA lo_el_is_data TYPE REF TO if_wd_context_element.
DATA ls_is_data TYPE wd_this->element_is_data.
DATA lv_empno TYPE wd_this->element_is_data-empno.
* navigate from <CONTEXT> to <IS_DATA> via lead selection
lo_nd_is_data = wd_context->path_get_node( path = `YSG_DEMO.CHANGING_1.IS_DATA` ).
lo_nd_is_data->get_lead_selection_index( ).
Hi This is the code that i wrote in WDINIT method. kindly can you edit and reply me plz....
Thanks
Sankar
Hi Chris,
I respect your opinion.
I believe, context mapping is more confusing. Moreover it is inefficient in performance as compared to attributes.
When we use context mapping, I am sure framework must use abap class to achieve it, thatu2019s how framework implement things implicitly. If we use attributes tab, we have more flexibility as we do it our self.
I think, people should know about other alternates available to them. And framework also provides attribute WD_COMP_CONTROLLER at view level to directly access info at component controller level.
Regards
Anurag Chopra
Hi Anurag,
>I believe, context mapping is more confusing.
We'll just have to agree to disagree on this one.
Given that context mapping is the standard SAP method for data transport between component controller and view (I'll happily accept that singleton class variables are often used cross component) I think that it is confusing within a single component to transport data in any way other than using the context. With the context mapping model it becomes clear what is being updated and when. You are not relying on any other additionally built mechanism to move the data. As you should (please don't say we disagree about using context mapping and not dynamically mapping values into UI elements) be using a context for populating your UI elements, then just mapping the context from the controller to the view is not a huge overhead. If the nodes in the component controller and views are named the same, have same structure - I fail to see how this is confusing.
Years ago I looked at using extreme programming (this was before we all started being agile) and one of the core understandings of that methodology has always stuck with me. The cost of improving your system hardware to counter any minor performance issues in code that arise from making the code easier to understand and maintain are far outweighed by the reduction in the support and development costs of the solution.
So I can see that using component attributes - and if you're that worried about performance why not use singleton class attributes?, you have even more control and better performance - might give you a slight performance gain, but I'd argue that it reduces the visibility of your data transport and unnecessarily complicates it.
But these are only my thoughts - I respect that you have yours too!
Hi Sankar,
I believe, you are using checkbx group and an end user can check few items, first we need to capture the information.
I am not sure on what event you are navigating to the second view. Before you navigate you could capture what all items were selected, for that you could use below code.
DATA lo_nd_info TYPE REF TO if_wd_context_node.
DATA lt_info TYPE wd_this->elements_info.
data tt type WDR_CONTEXT_ELEMENT_SET.
lo_nd_info = wd_context->get_child_node( name = wd_this->wdctx_info ).
lo_nd_info->get_static_attributes_table( IMPORTING table = lt_info ).
lo_nd_info->get_selected_elements( RECEIVING set = tt ).
In variable tt you have the info of the index. Now you have this info.
Now you could decide how you want to present selected item, things will not work implicitly you need to write code for it.
Regards
Anurag Chopra
User | Count |
---|---|
81 | |
24 | |
11 | |
9 | |
7 | |
5 | |
5 | |
5 | |
4 | |
4 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.