cancel
Showing results for 
Search instead for 
Did you mean: 

Colour Row of ALV

Former Member
0 Kudos

Hello,

I am using an ALV where I want to colour particular rows in it based on the content of a particular column (like whenever the value is TOTAL in that row) ,i want to color that entire row . How can i achieve the same.?

Please help.

Any help would be highly appreciated.

Thanks.

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

Hi,

Add a attribute CELL_COLOR of type WDY_UIE_LIBRARY_ENUM_TYPE in your context node.

Now according to you condition set the value of this attribute :-

like :-

LOOP AT IT_NODENAME INTO WA_NODENAME.

IF (condition ).

WA_NODENAME-CELL_COLOUR = CL_WD_TABLE_COLUMN=>E_CELL_DESIGN-GOODVALUE_LIGHT.

ENDIF.

ENDLOOP.

The colors details and types are given in the class CL_WD_TABLE_COLUMN.

Follow :-

[TableColumn|http://help.sap.com/saphelp_nw70/helpdata/en/bd/5d9041d3c72e7be10000000a1550b0/content.htm]

Now in after instantiating your alv component and using get model get the column reference and set the cell color attribute.

like:-

LO_CMP_USAGE = WD_THIS->WD_CPUSE_ALV_COMP( ).

IF LO_CMP_USAGE->HAS_ACTIVE_COMPONENT( ) IS INITIAL.

LO_CMP_USAGE->CREATE_COMPONENT( ).

ENDIF.

LO_INTERFACECONTROLLER = WD_THIS->WD_CPIFC_ALV_COMP( ).

DATA LV_VALUE TYPE REF TO CL_SALV_WD_CONFIG_TABLE.

LV_VALUE = LO_INTERFACECONTROLLER->GET_MODEL(

).

  • configure columns

LR_COLUMN_SETTINGS ?= LV_VALUE.

LT_COLUMNS = LR_COLUMN_SETTINGS->GET_COLUMNS( ).

as you want color a row so make it for all the columns:-

LOOP AT LT_COLUMNS INTO LS_COLUMN .

CASE LS_COLUMN-ID .

use this for all :-

LR_COLUMN->SET_CELL_DESIGN_FIELDNAME( VALUE = 'CELL_COLOUR' ).

ENDCASE.

ENDLOOP.

Regards,

Monishankar C

Former Member
0 Kudos

Hello Monishankar,

Thanks for the reply . I was able to colour the rows of the ALV conditionally , but now the CELL_COLOR attribute displays as a field in the ALV Table which I don't want to display . I can goto Settings of the ALV and remove the column and create a new View.

Or can i delete the cell column from the Internal Table just before binding it to the Node.

Please help.

Thanks.

Former Member
0 Kudos

Hi Developer,

That CELL_COLOR Attribute just bind with desing property of table column, and dont use as table column. u can remore from table lcolumn list.

Thanks,

Kris.

Former Member
0 Kudos

Hi SAPEPDeveloper,

Oh! I forgot to inform you about that.

Two thing you can do either hide it by changing visibility or delete it.

Here better you delete it from display .

Reply in case you need any assistance.

Regards,

Monishankar C

Answers (2)

Answers (2)

gill367
Active Contributor
0 Kudos

Hi

As suggested in the above post.

create an attribute of type WDUI_TABLE_CELL_DESIGN in the table node.

then bind all the columns's cell_Design property to it.

then set the value of this attribute based on the condition.

like you can do it where you are filling the table and binding it to the node.

Here is some sample code where i am checning the color based on the locatio = 'DELHI'

Data nd type ref to if_wd_context_node.
  data tbl type wd_this->elements_dealer.
  data line type wd_this->element_dealer.
  select * from zdealer into corresponding fields of table tbl.
    loop at tbl into line.
      if line-location = 'DELHI'.
      line-cell_design = '05'.
            MODIFY  TBL FROM LINE.
        ENDIF.
      endloop.

      ND = WD_CONTEXT->GET_CHILD_NODE( 'DEALER' ).
      ND->BIND_TABLE(
      TBL
      ).

thanks

sarbjeet singh

Former Member
0 Kudos

Hi Developer

Create one attribute CELL_DESIGN of type WDUI_TABLE_CELL_DESIGN in node. In the Properties of Table Column Properties there is one Field Called CellDesign.U Map the Attribute CELL_DESIGN for the Column which u want Color.If u want for a Row then map that attribute for each column.

how to set color based on some content and condition.. please check this wiki..

https://wiki.sdn.sap.com/wiki/display/Snippets/ABAPWebDynproALV-ChangeCellColourbasedonContent.

and also this

http://www.sdn.sap.com/irj/scn/go/portal/prtroot/docs/library/uuid/f0625002-596c-2b10-46af-91cb31b71...

If you want disfferent colors help see this link ...

http://help.sap.com/saphelp_nw70/helpdata/en/45/0ef14d9d942462e10000000a1553f7/frameset.htm.

Hope it can solve your problem.

Thanks,

Kris.

Edited by: kissnas on Feb 14, 2011 5:21 AM