cancel
Showing results for 
Search instead for 
Did you mean: 

create multiple elements dynamically at one time

Former Member
0 Kudos

Hi,

I need to create some links dynamically.

Below is my code... but I need to know instead of multiple steps.. is there a way to create dynamic elements together using one method itself.... or once i create the elements can i embed all these links together in the view?

lr_lta = cl_wd_link_to_action=>new_link_to_action(

id = 'LNK_CREATE'

on_action = 'ON_NAVIGATE'

text = 'Create'

view = lr_view ).

cl_wd_matrix_data=>new_matrix_data( element = lr_lta ).

lr_container->add_child( the_child = lr_lta ).

lr_lta = cl_wd_link_to_action=>new_link_to_action(

id = 'LNK_HISTORY'

on_action = 'ON_NAVIGATE'

text = 'Hitory'

view = lr_view ).

cl_wd_matrix_data=>new_matrix_data( element = lr_lta ).

lr_container->add_child( the_child = lr_lta ).

Any help will be grateful.

Regards and Thanks

Tenzin

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

Dear Tenzin,

I gather that you need to have multiple 'links to action' in your application and you want a method that creates say, five 'links to action' at one go.

You can create multiple links to action in a loop but calling the same method. So far, I have never come across a method that creates multiple links to action at one go.

You create them and embed them in your view.

Regards,

Prosenjit.

Former Member
0 Kudos

Hi,

In a loop as in to call a method? but how do i pass the element's id.. and one more doubt is that how do i insert the link divider( image element ) betweeen each of the links.

Any demo code will be really useful.

Thanks and Regards

Tenzin

Former Member
0 Kudos

Hi Tenzin,

Only way to get it created in one go is via loop, you can declare

ID with string concatenation as LTA_NAV1,LTA_NAV2,LTA_NAV3, LTA_NAV4....so on

ONACTION you can choose to keep same 'ON_NAVIGATE' later you can check within it from what link the ACTION originated. check my prev thread on this.

[]

Greetings

Prashant

Former Member
0 Kudos

Hi,

This is a sample code for doing it using loop.

I just refined the code to make it most amenable to your requirement.

The code gives two different links at the same time with two different actions.

method WDDOMODIFYVIEW .

IF first_time eq abap_true.

data lr_ref type ref to cl_wd_link_to_action.

data lr_cont_ref type ref to cl_wd_uielement_container.

data lr_layo_ref type ref to cl_wd_flow_data.

data lv_times type i value 2.

data lv_count type i value 1.

lr_cont_ref ?= view->get_element( 'ROOTUIELEMENTCONTAINER' ).

do lv_times times. "decide how many times you want the link

case lv_count. "decide what link to action with what action should be defined

when 1.

CALL METHOD cl_wd_link_to_action=>new_link_to_action

EXPORTING

enabled = ABAP_TRUE

image_first = ABAP_TRUE

on_action = 'First_Action'

text = 'First Link' "to display 'Gangtok' when clicked

receiving

control = lr_ref

.

CALL METHOD cl_wd_flow_data=>new_flow_data

EXPORTING

element = lr_ref

receiving

control = lr_layo_ref

.

CALL METHOD lr_cont_ref->add_child

EXPORTING

index = 1 "this is to set link to action in first place

the_child = lr_ref

.

When 2.

CALL METHOD cl_wd_link_to_action=>new_link_to_action

EXPORTING

enabled = ABAP_TRUE

image_first = ABAP_TRUE

on_action = 'Second_Action' "to display 'Kolkata' when clicked

text = 'Second Link'

receiving

control = lr_ref

.

CALL METHOD cl_wd_flow_data=>new_flow_data

EXPORTING

element = lr_ref

receiving

control = lr_layo_ref

.

CALL METHOD lr_cont_ref->add_child

EXPORTING

index = 2 "this is to set the link to action in 2nd place

the_child = lr_ref

.

endcase.

lv_count = lv_count + 1.

enddo.

endif.

endmethod.

Regards,

Prosenjit.

Edited by: prosenjit chaudhuri on Feb 16, 2009 12:48 PM

Former Member
0 Kudos

Hi,

Actually the funny part is Kanakraj and we both are working on the same project.. I have seen the thread already.

Anyways thanks for ur time.

Regards

Tenzin

Answers (0)