cancel
Showing results for 
Search instead for 
Did you mean: 

Getting selected items into next view

former_member222068
Active Participant
0 Kudos

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

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

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.

Answers (4)

Answers (4)

former_member1151507
Participant
0 Kudos

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

former_member1151507
Participant
0 Kudos

Hi,

You can use get_selected_elements( ) method of if_wd_context_node to get the selected elements.

Regards,

Manogna

Madhu2004
Active Contributor
0 Kudos

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.

former_member222068
Active Participant
0 Kudos

Hi Madhu,

i did the same as you said but all the items that were selected and not selected are displaying in the next view actually that was the reason why i raised this thread.

kindly can you tell me alternative method for this issue...

Thanks

Sankar

Madhu2004
Active Contributor
0 Kudos

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

former_member222068
Active Participant
0 Kudos

sorry madhu i tried this but i am getting the same result......

Former Member
0 Kudos

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

former_member222068
Active Participant
0 Kudos

Hi Anurag,

kindly can you elibarate your view, actually i could not understand what you said.

what i understood is i have a node in context and attributes under the node and this is copied and mapped in other view.

Thanks

Sankar

Former Member
0 Kudos

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

ChrisPaine
Active Contributor
0 Kudos

>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.

former_member222068
Active Participant
0 Kudos


  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

Former Member
0 Kudos

Hi ,

What are you trying to do in the code posted by you?

1.) are you trying to read all selected elemnts and copy it to another context node or

2.) using the same context node in both views??

Please clarify so that we could help you out..

Regards,

Aditya.

Former Member
0 Kudos

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

former_member222068
Active Participant
0 Kudos

Hi,

i have common node for both view 1 and view2 . Now what i am trying is i should get only the checked items( selected ) in view1 should be displayed in view2.

Thanks

Sankar

ChrisPaine
Active Contributor
0 Kudos

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!

Former Member
0 Kudos

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

former_member222068
Active Participant
0 Kudos

This message was moderated.

Former Member
0 Kudos

Hi,

Sankar is my friend ,

Different context node is using to get get selected checkbox values and

show in another view ....