cancel
Showing results for 
Search instead for 
Did you mean: 

work around context elements

siongchao_ng
Contributor
0 Kudos

Hi all,

I have a context node cardinality 0..n

I need this to render a set of ui elements.

Let say the node have 2 attributes named bank1 and bank2.

Every time user click on a button 2 add a new set of 2 input fields bank1 and bank2. I will add this towards the context node.

Now let say there are already 3 sets of ui elemnents and 3 sets of context elements.

Set 1

Set 2

Set 3

The problem: User can only always delete the most recent set but not set 1 or set 2. How to allow user to cherry pick which set to delete?

Accepted Solutions (0)

Answers (3)

Answers (3)

siongchao_ng
Contributor
0 Kudos

What I did was:

1. Delete and re-arrange my itab ( in delete action )

2. Remove all UI elements (wddomodifyview)

3. Invalidate all context elements (wddomodifyview)

4. Rebind the context with the re-arrange itab (wddomodifyview)

5. Re-render the UI elements with the re-arrange itab (wddomodifyview)

saravanan_narayanan
Active Contributor
0 Kudos

Hello siong,

please dont create two threads for the same problem. Close the other thread if its not answered and always have one thread for one problem.

in your use case retaining the mapping between the UI elements id and context element index will be a problem in the deletion case. Because if you delete a context element, the index of other elements will be changed automatically. But your UI element Id wont be changed.

Workaround/solution for your usecase

1. Whenver the user clicks on delete button, always delete the last set of UI elements. But in the context node, delete the respective context element (context element of respective index)

ex: if you have 3 set of UI elements, if the user opts to delete the first set, then delete the 3rd set if UI elements and delete the context element of index '1'.

in the same scenario if the user opts of delete the 2nd set of ui elements, then delete the 3rd set of UI elements and delete the context element of index '2'.

Former Member
0 Kudos

Did you provide any button for deletion against each set...

Or else you can do one thing...If a user clicks on button for deletion...show the user a popup for those UI elements that needs to be deleted by giving a checkbox against each set...so that those which are checked can be deleted at one go..

siongchao_ng
Contributor
0 Kudos

Hi Lekha,

Besides each set of ui elements, I have already rendered a delete button for user to delete that chosen set.

In the delete action button, I put in my codes to delete the ui elements (input fields, text views etc )

In the wddomodifyview, I put in codes to delete the context elements.

The code to delete the context elements:

lo_node = wd_Context->get_child_node( name = if_v_main=>wdctx_infotype9_render ).

lo_elem = lo_node->get_element( index_no).

lo_node->remove_element ( lo_node ).

Set 1

Set 2

Set 3

Problem: User can only start to delete from set 3 onwards, then set 2, then set 1 etc. If user delete set 1 or set 2 first, dump error will be triggered. What is wrong with my delete codes?

Former Member
0 Kudos

Hi,

what is the dump that you are getting..May be when you first delete the 2nd one...the index is not set properly..

I think before you delete, you need to reset the index and then delete...

Statically..when we design the layout...if we try to remove the UI element...we need to check howthe standard is resetiing..

Can you post the dump...

siongchao_ng
Contributor
0 Kudos

Hi Lekha,

The dump error message:

Adaptor error in INPUT_FIELD "INP_002_BANK_ACCOUNT" of view "view_name": Context binding of property value cannot be resolved: Element with index 2 does not exist; context node: V_INFOTYPE9.1.INFOTYPE9_RENDER.

So after I delete the context element with the codes I posted earlier, do I need to do anything more like re-arranging the context elemnts or something? Post the codes pls.

Former Member
0 Kudos

Hi,

To delete selected element from table .

Insted of this statement..

lo_node->remove_element ( lo_node ).

write..

lo_node->remove_element (lo_elem ).

Cheers,

Kris.

siongchao_ng
Contributor
0 Kudos

Hi kissnas,

The problem is not about removing element.

I have dynamically rendered several sets of ui elements (input fields/text view/drop down etc )

All these input fields/drop downs are bind to context node cardinality 0..n with their respective attributes.

Say there 3 sets of ui elements now,

Set 1

Set 2

Set 3

User can only delete the most recent set like set 3 then followed by set 2 and set 1. The program supposed to let user delete any set they wish. How to do that?

To better understand the problem:

initially say three input elements added

1. Input 1 - Binding -> INFOTYPE9_RENDER.1.BANKN -> value = "Account1"

2. Input 2 - Binding -> INFOTYPE9_RENDER.2.BANKN -> value = "Account2"

3. Input 3 - Binding -> INFOTYPE9_RENDER.3.BANKN -> Value = "Account3"

now if the user deletes the first input set. you are deleting the context element 1. Once you delete the first element, the index of second element will be automatically changed from 2 to 1 and same for 3rd element from 3 to 2.

so after deleting the first element your context collection will look like this

INFOTYPE9_RENDER.1.BANKN -> value = "Account2"

INFOTYPE9_RENDER.2.BANKN -> value = "Account3"

there wont be any element with index 3. But your 3rd input is still pointing to INFOTYPE9_RENDER.3.BANKN which is not available in the context collection.

so in this case you need to change the binding of the reminaing two input fields

1. Input 2 - Binding -> INFOTYPE9_RENDER.1.BANKN -> value = "Account2"

2. Input 3 - Binding -> INFOTYPE9_RENDER.2.BANKN -> Value = "Account3"

How do I reset the binding of the 2 remaining input fields?