cancel
Showing results for 
Search instead for 
Did you mean: 

How to set particular column or cell color of result view in CRM WEB UI ?

Former Member
0 Kudos

Hi experts,

How to set particular column or cell color of result view in CRM WEB UI using IF_HTMLB_TABLEVIEW_ITERATOR interface ?

Is there any solution ?.

Regards,

Vishal

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

Hi Vishal,

I also have the same problem. In my thread [http://forums.sdn.sap.com/thread.jspa?threadID=2128064&tstart=0|http://forums.sdn.sap.com/thread.jspa?threadID=2128064&tstart=0], I described the steps I've done, I believe it's more detailed than yours, but seems no one is interested in it, as I'm new to WEBUI, I think maybe I'm wrong because guys around me kept telling me that SAP CRM WEBUI is not a web page, we need to focus on business, not just the layout, so I finally had to give up.

Luckly to see that your thread has some replies, it gives me the hope to solve that problem:). So if you get the solution, please have a post. Thank you very much!

Best Regards,

Jeff

VishnAndr
Active Contributor
0 Kudos

Hi All.

Some time ago I dug in this topic too.

And what I found out is:

Table view iterator (represented by the class which implements IF_HTMLB_TABLEVIEW_ITERATOR interface) has parameters in method RENDER_CELL_START:

Exporting

P_REPLACEMENT_BEE

Changing

P_STYLE

P_CLASS

P_ISREADONLY

P_ISHIERCELL

So far so good. But if you use chtmlb:configTable or chtmlb:configCellerator or thtmlb:cellerator (in fact first two BSP elements finish their way with thtmlb:cellerator) the call stack will be:

RENDER_CELL_START from your iterator

RENDER_CELL_START from CL_CHTMLB_CONFIG_TABLE (for chtmlb:configTable) or CL_CHTMLB_CONFIG_CELLERATOR (for chtmlb:configCellerator)

GET_CELL_CONTENT from CL_THTMLB_CELLERATOR

And the reason is in this last method. Because it doesn't receive any changing parameters from iterator. Only replacement bee.

ITERATOR->RENDER_CELL_START(
       EXPORTING
         P_TABLEVIEW_ID  = ME->ID
         P_CELL_ID       = LV_CELL_ID
         P_CELL_BINDING  = LV_CELL_BINDING
         P_ROW_INDEX     = IV_ROW_INDEX
         P_ROW_KEY       = IV_ROW_KEY
         P_COLUMN_INDEX  = IV_COLUMN_INDEX
         P_COLUMN_KEY    = IS_COLUMN_DEFINITION-NAME
         P_ROW_DATA_REF  = IV_ROW_DATA_REF
         P_EDIT_MODE     = IV_EDIT_MODE
      IMPORTING
         P_REPLACEMENT_BEE = LV_BEE
   ).

So P_STYLE and others are not taken into account.

The option probably is to use own BSP element which has style attribute itself, create it in RENDER_CELL_START of own iterator and return it as P_REPLACEMENT_BEE. Never tried it myself.

BTW, It seems that tree's stack of tags (chtmlb:configTree, thtmlb:tree) and general table tag thtmlb:tableView work with these parameter as expected. You can try it by yourself or just take a look into element handler classes of this tags and find a call of RENDER_CELL_START of iterator.

Hope this will help you!

Former Member
0 Kudos

Hi Andrei Vishnevsky,

In my case I am able to edit the column or read the column or put the value into column but I am not able to put the colour into column, Because P_STYLE parameter is optional, and I am putting the value into P_STYLE, but it is not reflecting .

Regards,

Vishal.

Former Member
0 Kudos

Hi liu jinghui,

I am doing same way as you have given link, but In my case I am able to edit the column or read the column or put the value into column but I am not able to put the colour into column, Because P_STYLE parameter is optional, and I am putting the value into P_STYLE, but it is not reflecting .

Regards,

Vishal.

VishnAndr
Active Contributor
0 Kudos

It's because as I pointed above P_STYLE is not taken into account by the SAP system. You can set it or not, system won't take it if you use any tag which in fact finish with cellerator.

Former Member
0 Kudos

Hi,

"You can set it or not, system won't take it if you use any tag which in fact finish with cellerator." Means???? I am not getting.

How system will take?

Regards,

Vishal

VishnAndr
Active Contributor
0 Kudos

Vishal,

please read my answer above (exactly this message: http://forums.sdn.sap.com/message.jspa?messageID=11127647#11127647)

You set P_STYLE in your iterator.

It is transfered to CL_CHTMLB_CONFIG_TABLE or CL_CHTMLB_CONFIG_CELLERATOR (depends on which tag you use).

Then it is transfered to CL_THTMLB_CELLERATOR.

But CL_THTMLB_CELLERATOR doesn't take it. It only takes P_REPLACEMENT_BEE as you can see in the code above.

Former Member
0 Kudos

Hi Andrei,

Thank you very much for the post. Do you mean the sequence of method RENDER_CELL_START is first my own iterator then CL_CHTMLB_CONFIG_TABLE and finally CL_THTMLB_CELLERATOR and thus the latter CL_THTMLB_CELLERATOR will ignore the previous P_STYLE parameter value?

If that's your mean, I don't think it's the truth, I did a debug and found the sequence is first CL_THTMLB_CELLERATOR then CL_CHTMLB_CONFIG_TABLE and finally my own iterator, so it should work.

At present, I do not want to use alternative ways like BSP page or some other tags as you mentioned.

Please clarify if I'm wrong.

plus:

I also tried P_REPLACEMENT_BEE as you mentioned but failed.

Thank you very much!

Regards,

Jeff

Edited by: liu jinghui on Feb 29, 2012 11:40 AM

VishnAndr
Active Contributor
0 Kudos

Jeff,

I mean exactly what I've said.

As far as we are talking about changing (e.g. returning) parameters we need to check not how you get to your iterator. Instead we need to check the calling back sequence from your iterator because we're wondering how this parameters are returned to top calling instance. And it is as I've said:

your iterator -> CL_CHTMLB_CONFIG_TABLE -> CL_THTMLB_CELLERATOR

Just debug father after your code in iterator. Where do you go after ENDMETHOD statement of your RENDER_CELL_START method in iterator?

Former Member
0 Kudos

Hi Andrei,

I did it as you adviced, yes, after my iterator, it comes back to CL_CHTMLB_CONFIG_TABLE and then CL_THTMLB_CELLERATOR. So I got your mean why P_STYLE not work.

But still to my supprise, why P_REPLACEMENT_BEE also not work? I use the statement

concatenate '<font color=""red"">' WF_TEXT '</font>' into html_str.
        create object html_bee.
        html_bee->add( html = html_str ).
        p_replacement_bee = html_bee.

and I can see thru debug that p_replacement_bee does transfer to method GET_CELL_CONTENT in CL_THTMLB_CELLERATOR, in the line #258 in GET_CELL_CONTENT, LV_HTML is set as I expected. But after the method, everything remains unchange. So strange.

Do you have the same issue?

Jeff

VishnAndr
Active Contributor
0 Kudos

No, Jeff, sorry. I didn't debug deeper.

Former Member
0 Kudos

Hi Vishal,

I finally found a solution how to set color for cells. Actually, I was very close to the success, but I wrote wrong BEE code.

You can refer my previous mentioned thread [http://forums.sdn.sap.com/thread.jspa?threadID=2128064&tstart=0|http://forums.sdn.sap.com/thread.jspa?threadID=2128064&tstart=0]

There I remarked the P_REPLACEMENT_BEE

*        concatenate '&lt;font color="" red""&gt;' 
*         WF_TEXT '&lt;/font&gt;' into html_str. 
*        create object html_bee.
*        html_bee->add( html = html_str ).
*        p_replacement_bee = html_bee.        "not work either

because I tried and it did not work, so I thought I was using wrong method. You can just unmark the upper codes and remove the duplicated quote around the font color "red" and make it become: concatenate '&lt;font color="red"&gt;' WF_TEXT '&lt;/font&gt;' into html_str. If you want to set background color, you can embedded some HTML code like &lt;span style="background-color:#00FF00"&gt;...&lt;/span&gt;. Than it will work. I already can enjoy the beautiful colors now:).

Thank Andrei greatly for the discovery!!! You know I have struggled on it for weeks, today is really an exciting day!

Jeff

Edited by: liu jinghui on Feb 29, 2012 4:51 PM

VishnAndr
Active Contributor
0 Kudos

Good job, Jeff!! Nice to hear that you've got the solution.

Former Member
0 Kudos

Hi liu jinghui,

Thank you very very very very very very very very very very much. I got the output now I am very happy, Because I was suffering from previous 1 month, I have been given you points, Thank you Thank you Thank you.

Regards,

Vishal.

Former Member
0 Kudos

Hi Andrei Vishnevsky ,

Thank you very very very very very very very very very very much. I got the output, Now I am very happy, Because I was suffering from previous 1 month for this, I have been given you points,, Thank you Thank you Thank you.

Regards,

Vishal.

Answers (4)

Answers (4)

former_member267851
Participant
0 Kudos

Hi Vishal,

I have the same requirement , change the row color according to status.

Plz have a look the same issue.

http://scn.sap.com/thread/3479317

Thanks and regards

Alok

0 Kudos

hi GE,

Everybody.. Need help tree profile.

I need to freeze the Tree Columns.. ie I don't want colums to be dragged to other location.. Can Some body guide me  here.

thanks and Regards,

Jaffer vali shaik

Former Member
0 Kudos

Hello, I am sorry but what kind of type the variable WF_TEXT has? What kind of values could be included as an example?

Former Member
0 Kudos

Hi Oliver,

Thanks for your interest. Actually the variable WF_TEXT will contains the field's value (just for condition to color the field value).

Please refer the below code for your reference. Please feel free to query.

Example: Suppose we have a column 'CREATED_BY' in table view and when this field will have the value 'SAPUSER'  then color it.

CASE p_column_key.

          WHEN 'CREATED_BY'. "// Field name

                     READ TABLE me->gt_result INTO ls_order INDEX p_row_index.

                              IF sy-subrc NE 0.

                                        EXIT."===========>>>

                              ENDIF.

                    ASSIGN COMPONENT p_column_key OF STRUCTURE ls_order TO <col>.

                              IF sy-subrc = 0.

                                        wf_text = <col>.

                              ENDIF.


                    IF wf_text = 'SAPUSER'. "// If specific field Value found, then color it

                              CONCATENATE '<font color="red">' wf_text '</font>' INTO html_str. "//Setting red color for column text

                              CREATE OBJECT html_bee.

                              html_bee->add( html = html_str ).

                              p_replacement_bee = html_bee.

                    ENDIF.

ENDCASE.

Regards,

Vishal.

Former Member
0 Kudos

Very helpfull, I tried it and it worked well, Thanks Vishal.

Former Member
0 Kudos

Hi Vishal,

thank you it works now. I was able to set the font colour to red. But could you maybe tell me please how to set the background color for the entire cell to red?

I have opened the thread:

http://scn.sap.com/thread/3411004

for this.

Thank you,

Former Member
0 Kudos

Hi Leon,

Thanks for reply,

I am doing but not able to color a cell can you help me please?

Regards,

Vishal

0 Kudos

Hi Vishal,

You need to modify the changing parameter P_STYLE in the corresponding method.

Get the parameter and modify it by adding the color information. Once modified

the style info looks something like 'padding-left:4px;padding-top:2px;padding-right:2px;background-color:#efefef'.

You can find the corresponding column with the importing parameters, P_COLUMN_INDEX , P_COLUMN_KEY.

Regards,

Leon

Former Member
0 Kudos

Hi Leon,

Can you describe it in detail ?

Because , I am not getting.

Regards,

Vishal

Former Member
0 Kudos

Hi Leon,

I am doing like this:


method IF_HTMLB_TABLEVIEW_ITERATOR~RENDER_CELL_START.

  data: V_PROMPT type STRING.
  case P_COLUMN_KEY.

    when 'CATEGORY'.
      if P_EDIT_MODE is not initial.
        data: WORK_ORDER type STRING.
**********************************************************************
        call method CL_HTMLB_INPUTFIELD=>FACTORY
          exporting
            CELLVALUE = 'TRUE'
            DESIGN    = 'STANDARD'
            ID        = P_CELL_ID
            STYLE     = 'celldesign:CRITICALVALUE_DARK'
          receiving
            ELEMENT   = P_REPLACEMENT_BEE.

**********************************************************************
        P_STYLE = 'celldesign:POSITIVE'.

      endif.


  endcase.

endmethod.



<%@page language="abap" %>
<%@extension name="thtmlb" prefix="thtmlb" %>
<%@extension name="chtmlb" prefix="chtmlb" %>
<%@extension name="htmlb" prefix="htmlb" %>
<%@extension name="bsp" prefix="bsp" %>
<%
  data lr_it type ref to ZCL_HTML_ITERATOR. "this class is implementing IF_HTMLB_TABLEVIEW_ITERATOR
  create object lr_it.
%>
 <chtmlb:configTable actionsMaxInRow       = "6"
     iterator              = "<%= lr_it %>"
     allRowsEditable       = "TRUE"
     id                    = "Table1"
     onRowSelection        = "select"
     personalizable        = "TRUE"
     selectedRowIndex      = "<%= Result->SELECTED_INDEX %>"
     selectedRowIndexTable = "<%= Result->SELECTION_TAB %>"
     selectionMode         = "<%= Result->SELECTION_MODE %>"
     table                 = "//Result/Table"
     usage                 = "EDITLIST"
     visibleFirstRow       = "<%= Result->VISIBLE_FIRST_ROW_INDEX %>"
     visibleRowCount       = "6"
     actions               = "<%= controller->gt_button %>"
     width                 = "100%"
     xml                   = "<%= controller->configuration_descr->get_config_data( ) %>"
     enableTableGraphics   = "TRUE" />

What is the problem in my code?

Regards,

Vishal.

0 Kudos

Hi Vishal,

I am not sure if you can give color information like this in the style parameter. Do you see any change in

the UI when you do this?

Can you try giving something like 'background-color:#efefef' as the style info and check.

Regards,

Leon

padma_guda
Participant
0 Kudos

Hi Vishal,

Were you able to solve the issue?

I am facing a similar issue, and it would be great if you could update the post with the solution approach followed.

Best Regards,

Padma

Former Member
0 Kudos

Sorry Padma,

I am not able to solved that problem that is my problem is not solved.

If you have any solution then please post me.

Regards,

Vishal.

Former Member
0 Kudos

Hi Padma,

I got the output for How to set particular column or cell color of result view in CRM WEB UI ?.

Please go through these link

)

,

and for any query reply me.

Regards,

Vishal.

0 Kudos

Hi Vishal,

Yes, you can achieve that by implementing the method IF_HTMLB_TABLEVIEW_ITERATOR~RENDER_CELL_START

of the corresponding interface.

Regards,

Leon