cancel
Showing results for 
Search instead for 
Did you mean: 

Light Indicator based on condition.

Former Member
0 Kudos

Hello Experts,

I am displaying some data in a table. Now i want some light indicator on row level based on a value of a perticular row.

I tried it by creating a attribute of string type and bind it to the UI element of the table of Image type. Now i am setting the value based on certian condition . But the light is coming only for the first row. But i want those light in every rows of the table.

Can you please tell me if i missed some thing .

Thanks,

Satya

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

Hello,

Please post the code which you are using to set the value of the String attribute based on condition.

May be theres something wrong in the way its done.

Regards,

Srilatha

Former Member
0 Kudos

Hi Srilatha,

Here you go..

loop at it_tab_ctrl into wa_tab_ctrl.

if wa_tab_ctrl-days LT 100.

DATA lv_light TYPE wd_this->Element_output-light.

  • navigate from <CONTEXT> to <OUTPUT> via lead selection

lo_nd_output = wd_context->get_child_node( name = wd_this->wdctx_output ).

  • get element via lead selection

lo_el_output = lo_nd_output->get_element( ).

  • @TODO handle not set lead selection

IF lo_el_output IS INITIAL.

ENDIF.

  • set single attribute

lo_el_output->set_attribute( name = `LIGHT` value = 'ICON_LED_GREEN' ).

elseif wa_tab_ctrl-days GT 100 and wa_tab_ctrl-days LT 105.

  • navigate from <CONTEXT> to <OUTPUT> via lead selection

lo_nd_output = wd_context->get_child_node( name = wd_this->wdctx_output ).

  • get element via lead selection

lo_el_output = lo_nd_output->get_element( ).

  • @TODO handle not set lead selection

IF lo_el_output IS INITIAL.

ENDIF.

  • set single attribute

lo_el_output->set_attribute( name = `LIGHT` value = 'ICON_LED_YELLOW' ).

else.

  • navigate from <CONTEXT> to <OUTPUT> via lead selection

lo_nd_output = wd_context->get_child_node( name = wd_this->wdctx_output ).

  • get element via lead selection

lo_el_output = lo_nd_output->get_element( ).

  • @TODO handle not set lead selection

IF lo_el_output IS INITIAL.

ENDIF.

  • set single attribute

lo_el_output->set_attribute( name = `LIGHT` value = 'ICON_LED_RED' ).

endif.

endloop.

Thanks,

Satya

Former Member
0 Kudos

Hello Satya,

you are looping through it_tab_ctrl and inside loop everytime you are trying to get the lead selected element. So in each iteration, you will be getting the same node element and you are modifying only that one. Hence you are seeing the image only in one row.

I am not sure how you are binding the data to the node which is mapped to the TABLE control. What you can do is, if you are binding an internal table to the node, before you do the binding add one more field of type Sting for image to that internal table(if its not there already) then loop through the internal table and based on the condition assign the value to that field.

After the loop end, bind the internal table to the node. Then it will work!

If you are not binding the data to node as a table, then what you can do is get all the context elements and loop through those elements. I hope the value which you use to check the condition is there as an attribute in the node. Then inside the loop, assign the value to the image attribute based on the condition.

Let me know if you didnt get what i have mentioned above. Will try to give code snippet!

Regards,

Srilatha

Former Member
0 Kudos

Hi Srilatha,

Thanks for the brief suggesion , yes i am binding the Internal Table to the node for the displaying the data . As you mentioned i already add one filed of type string for image. And before binding the table to the node i m trying to set the value for the light indicator. But it is not working for me .

Please advice.

Thanks,

Satya

Former Member
0 Kudos

Hi,

Here is a sample code:


DATA:  node_node_flighttab TYPE REF to if_wd_context_node,
             lt_flights TYPE if_componentcontroller=>Elements_Node_Flighttab,
             ls_flight type if_componentcontroller=>Element_Node_Flighttab,
             lv_seatsfree TYPE sflight-seatsmax.

* read data
  select * from sflight into corresponding fields of table lt_flights.

  LOOP AT lt_flights INTO ls_flight.
    lv_seatsfree = ls_flight-seatsmax - ls_flight-seatsocc.

    IF lv_seatsfree = 0.
      ls_flight-status = 'ICON_RED_LIGHT'.
    ELSEIF lv_seatsfree <= 50.
      ls_flight-status = 'ICON_YELLOW_LIGHT'.
    ELSE.
      ls_flight-status = 'ICON_GREEN_LIGHT'.
    ENDIF.

    MODIFY lt_flights FROM ls_flight.
  ENDLOOP.
* navigate from <CONTEXT> to <NODE_FLIGHT> via lead selection
  node_node_flighttab = wd_context->get_child_node( name = `NODE_FLIGHTTAB` ).
* fill context node
  node_node_flighttab->bind_table( lt_flights ).

Incase if you are still facing the issue , can you please post the code snippet?

Regards,

Srilatha

Edited by: Srilatha M on Jul 7, 2010 12:56 PM

Former Member
0 Kudos

Hi Srilatha,

Thanks a ton my problem is solved by refering your code.

Thanks,

Satya

Answers (0)