cancel
Showing results for 
Search instead for 
Did you mean: 

ABAP WD: Dynamic UI programming for controlling font size

srinivasa_raghavachar
Participant
0 Kudos

Hi,

I have a table with 2 columns: TreeByNestingTableColumn which has textview with ID 'NAME1' and ordinary table column which has textview with ID 'VALUE1'.

I am using the event OnLoadChildren for populating TreeByNestingTableColumn.

Everything works fine, except that I need to show the value of textview 'NAME1' within TreeByNestingColumn in different fonts based on the value in column 'VALUE1'.

I figured out I would have to use WDDOMODIFYVIEW for this.

I guess I would have to access the TABLE UI element, get the rows, loop at each row, get the value of column 'VALUE1' and set the font of 'NAME1' based on its value.

My code looks something like this:

data: text_view1 type ref to CL_WD_TEXT_VIEW,

text_objecttype type ref to CL_WD_TEXT_VIEW,

text_table type ref to CL_WD_TABLE,

element type ref to IF_WD_CONTEXT_ELEMENT,

ui_value type string,

wd_table_column type ref to cl_wd_table_column,

wd_table_columns type standard table of ref to cl_wd_table_column.

text_table ?= view->GET_ELEMENT( ID = 'COURSEDETAILS' ).

wd_table_columns = text_table->get_columns( ).

loop at wd_table_columns into wd_table_column.

text_view1 ?= view->GET_ELEMENT( ID = 'NAME1' ).

text_objecttype ?= view->GET_ELEMENT( ID= 'VALUE1' ).

ui_value = text_objecttype->GET_TEXT( ).

CONDENSE ui_value.

if ( ui_value <> 'L' ).

text_view1->SET_DESIGN( VALUE = '09' ).

endif.

ENDLOOP.

endif.

The problem is that I do not need columns, but I need rows and I have not been able to figure out how to get rows and in this example 'VALUE1' always gets the value of first row.

1) Could you please give me a sample code how to do it?

2) In my case the code within WDDOMODIFYVIEW has to be always called (I can not use if first_time = abap_true)since I fetch the data in the table through OnLoadChildren event and in that case I would have to always loop through table contents in the WDDOMODIFYVIEW. Is there a better way than this?

Regards,

Srini.

Accepted Solutions (1)

Accepted Solutions (1)

Ulli_Hoffmann
Contributor
0 Kudos

Hi Srini,

i'd suggest not do set the design by dynamic view modification.

There is an easier way to that:

You can bind the property 'design' of the cell-editor element to an additional attribute in the context-node to which your table bounds.

Set this attribute with the design-value in the supply-function for every element (row) and later in the event-handler method.

Don't use absolut values. Use constants:

CL_WD_TEXT_VIEW=>e_design-emphazied

CL_WD_TEXT_VIEW=>e_design-header1 .....

regards, Ulli

srinivasa_raghavachar
Participant
0 Kudos

Hi Ulli,

Thanks for the answer.

I agree that it is an easier way of doing it. But my requirement is quite complex. Actually based on the value of 'VALUE1', I need to show different UI elements instead of the text view 'NAME1' like textview, hyperlink etc.

Can we do such a scenario? I guess it can be done only in WDOMODIFY, hence I was trying to set the font as a first step.

Regards,

Srini.

Ulli_Hoffmann
Contributor
0 Kudos

Hi Srini,

ok, in that case you must use cell-variants. In the column element there is a property called selectedCellVariant. This is bound to a new attribute of the context-node to which the table bounds. Fill the attribute with unique id for each element(row). Then, in wddomodify()

1) loop over the context

2) determine the row you like to change

3) create a new view element and set the design

4) create a new cell and pass the variant key

5) add the new view element to the cell object

6) add the cell object to the column

Following find some code for a linkToAction element

lr_lta = cl_wd_link_to_action=>new_link_to_action(

view = view

on_action = 'GO'

text = ls_data-default_value ).

lr_standard_cell = cl_wd_table_standard_cell=>new_table_standard_cell(

view = view

variant_key = ls_data-variant ).

lr_standard_cell->set_editor( lr_lta ).

lr_table_column->add_cell_variant( lr_standard_cell ).

regards, Ulli

Answers (0)