cancel
Showing results for 
Search instead for 
Did you mean: 

Change attribute of row in table

Former Member
0 Kudos

Hi friends!

I have a table where I select one row and press a button.

I then want a specific field on that selected row to have its attribute [semanticColor] changed from [standard] to [positive].

Used declarations:

DATA lo_nd_lista TYPE REF TO if_wd_context_node.
  DATA lo_el_lista TYPE REF TO if_wd_context_element.
  DATA lo_el_context TYPE REF TO if_wd_context_element.

First I point out which row that is selected:


  lo_nd_lista = wd_context->get_child_node( name = wd_this->wdctx_lista ).
  IF lo_nd_lista IS INITIAL.
  else.
    lo_el_lista = lo_nd_lista->get_lead_selection(  ).
    IF lo_el_lista IS INITIAL.
    else.
      lo_el_lista->get_static_attributes( IMPORTING static_attributes = ls_lista ).
        move-corresponding ls_lista to ls_zharfid.
    ENDIF.
  ENDIF

.

Then I try to set the attribute [semanticColor] for that row


lo_el_context->set_attribute(
*  lo_nd_lista->set_attribute(
    EXPORTING
      value = 'positive'
      name =  'semanticColor' ).

When using lo_el_context->set attribute ....I get. "Access via 'NULL' object reference not possible."

When using lo_nd_lista->set attribute...I get "Could not find attribute semanticColor "

I'm afraid I haven't got the hang of how the attribute is reached.

Please give me a hand...

Best reg

Henrik

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

Hi,

Check the attribute name binded to the table column...

As you have said ..no such attribute exists...u mite have mispelled the attribute name

If till doesnt work,get the lead selection index and check..using get_lead_selection_index

Using index u can easily read the content of the row of the selected index.

Hope it helps!!!!

Thanks,

Divya.S

Former Member
0 Kudos

Hi again!

I beliave my question is wrong. It is the property of a textview in a table I want to change.... see below.

Maybe the statements below will help you help me

My layout-table RESULT has binding to CONTEXT:

Node: LISTA (0..n)

Attribute: MATNR

Attribute: ....

Layout:

RESULT - name of table (table)

RESULT_MATNR - name of column (tablecolumn)

RESULT_MATNR_EDITOR - name of textview (textview)

It is of textview RESULT_MATNR_EDITOR I find the property semanticColor.

Best reg

Henrik

Former Member
0 Kudos

Hi,

If u want to change the text color...

U hav to have one more attribute ,say,COLOR in addition to other attributes in ur node LISTA.

And this attribute should be bind to the Semantic color property of ur text view.

So at run time,when u select the row,set the color accordingly using set_attribute

For data type for the attribute ,in se11,type as semanticcolor* and press F4.

Rite now i m not infront of the system. Once u find the data element,u can see the corresponding values as

00,01 ... for statndard,positive.....

Hope dis helps!!!!!

Thanks,

Divya.S

Former Member
0 Kudos

Im so close!!! Now ALL rows for that column turns GREEN...not only the selected one....

I've added:

Context:

COLOR: Attribute of type WDUI_TEXTVIEW_SEM_COL

Layout:

Binding from

RESULT (table)

RESULT_MATNR (tablecolumn)

RESULT_MATNR_EDITOR (textview)

>> Property semanticColor BIND TO Context attribute COLOR

But with my coding i gett ALL the rows in the table to be green when button is pressed.

I only want the selected one to be green.

lo_el_context = wd_context->get_element(  ).
  lo_el_context->set_attribute(
    EXPORTING
      value = '02'
      name =  'COLOR' ).

I point out the selected row via:

lo_nd_lista = wd_context->get_child_node( name = wd_this->wdctx_lista ).
    lo_el_lista = lo_nd_lista->get_lead_selection(  ).
      lo_el_lista->get_static_attributes( IMPORTING static_attributes = ls_lista ).
        move-corresponding ls_lista to ls_zharfid.

Do you perhaps have the final missing part of this mystery?

Best reg

Henrik

Former Member
0 Kudos

Hi,

In the button handler, you hve to bind the table again with these changes.

Now you got the lead selection index right into some lv_index right.

Loop at lt_table into ls_table

if sy-tabix eq lv_index.

ls_table-color = '02'.       "green
else.
ls_table-color = '03'.     "Some other
endif.
modify lt_table from ls_table index sy-tabix.
endloop.

lo_nd_node->bind_table( lt_table).

Former Member
0 Kudos

Excellent!!!

It works !!!

Thankyou very much for your wonderful support!

Best reg

Henrik

Answers (1)

Answers (1)

Former Member
0 Kudos

Hi,

For that Node, is the Initialization Lead selection should be checked and also for the table UI element, is the leadselection set to Single or not. Please cross check it.

Regards,

Lekha.