cancel
Showing results for 
Search instead for 
Did you mean: 

dynamic tooltips on alv column

Former Member
0 Kudos

I am displaying one alv column as the traffic lights icon.

Depending on whether it is red, yellow or green, i want to have a different tooltip for this column.

is this possible? if yes then can someone please tell me how to do it?

regards,

Priyank

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

Hi Priyank.

You can achieve this using different cell variants for the alv column. For each

variant you define a new cell editor where you can set the tooltip.

You can bind the selection of which variant have to be used to the column itself or

add a new column to your node which is only for this purpose.

have a look at the ON_UPLOAD_COMPLETE method of the component controller

of the WD4A component SALV_WD_DEMO_TABLE_CV.


...
if l_erg eq 0.
      ls_data-cellvariant = 'TEXT_VIEW'.
else.

In some cases the field cellvariant is set to text view.

Go down in the method you will find this:


loop at lt_columns into ls_column.
*... create textview cellvariant for each column
    data:
      lr_cv type ref to cl_salv_wd_cv_standard.

    create object lr_cv.

    lr_cv->set_key( 'TEXT_VIEW' ).

    data:
      lr_textview type ref to cl_salv_wd_uie_text_view.

    create object lr_textview.
    lr_textview->set_text_fieldname( ls_column-id ).

    lr_cv->set_editor( lr_textview ).

    ls_column-r_column->add_cell_variant( r_cell_variant = lr_cv ).

    ls_column-r_column->set_sel_cell_variant_fieldname( 'CELLVARIANT' ).

Here the cellvariant is added to the column and the filedname that contains the

variant to choose is set via set_sel_cell_variant_fieldname( 'CELLVARIANT' ).

This mean that in each row the field cellvariant is checked and if it contains the

text 'TEXT_VIEW' the cell variant is used.

You could set up the tooltip of each cell editor you use for each cell vraiant. In the

above example it wozuld be something like this:


create object lr_textview.
lr_textview->set_text_fieldname( ls_column-id ).
lr_textview->set_tooltip( 'TOOLTIP FOR TEXTVIEW CELL VARIANT' ).

Hope this helps.

Cheers,

Sascha

Former Member
0 Kudos

Hi Sascha,

Sorry for this late response. I think the code you have given for reference is going to set the property for the entire column. What i want is a cell-wise tooltip, means a different tooltip for each row of the column.

I was wondering if it is possible to set the content of one column of the row as the tooltip of another column. Means if i include another column in my node and then i set the content of this column as the tooltip of another column . Is such a thing possible?

regards,

Priyank

Former Member
0 Kudos

Hi Pri.

No, when you use cell variants you initially define available cell variants at column

level, but which variant to use is defined on row level. In the example you can

switch between two variants on row level. The decission which variant to use is

defined thru the field CELLVARIANT for each row.

Cheers,

Sascha.

Former Member
0 Kudos

Well Sascha,

Thanks for the response but i have a slight change in requirement now. The tooltip content will have to be fetched from the backend (database level) now through the function module which is returning the data to be displayed in the ALV. Thus, the option that seems available now is to get the tooltip content in another column in the alv, keep this column hidden and use the content of this column as the tooltip for the traffic lights column.

Any direct way of doing this?

By the way i tried using the following code in the domodifyview method to see if it works....did not work for me....let me know what wrong i might have been doing.

DATA: l_ref_cmp_usage TYPE REF TO if_wd_component_usage,

l_ref_interfacecontroller TYPE REF TO iwci_salv_wd_table,

l_value TYPE REF TO cl_salv_wd_config_table.

l_ref_cmp_usage = wd_this->wd_cpuse_alv( ).

IF l_ref_cmp_usage->has_active_component( ) IS INITIAL.

l_ref_cmp_usage->create_component( ).

ENDIF.

l_ref_interfacecontroller = wd_this->wd_cpifc_alv( ).

l_value = l_ref_interfacecontroller->get_model( ).

DATA: lr_column_settings TYPE REF TO if_salv_wd_column_settings,

lr_column TYPE REF TO cl_salv_wd_column.

lr_column_settings ?= l_value.

DATA:

lt_columns TYPE salv_wd_t_column_ref.

lt_columns = lr_column_settings->get_columns( ).

DATA:

ls_column TYPE salv_wd_s_column_ref.

LOOP AT lt_columns INTO ls_column.

DATA: lr_cv TYPE REF TO cl_salv_wd_cv_standard.

CREATE OBJECT lr_cv.

lr_cv->set_key( 'ICON_GREEN_LIGHT' ).

DATA: lr_textview TYPE REF TO cl_salv_wd_uie_text_view.

CREATE OBJECT lr_textview.

lr_textview->set_text_fieldname( ls_column-id ).

lr_textview->set_tooltip( 'TOOLTIP FOR GREENLIGHT' ).

lr_cv->set_editor( lr_textview ).

ls_column-r_column->add_cell_variant( r_cell_variant = lr_cv ).

ls_column-r_column->set_sel_cell_variant_fieldname( 'EXPIRYSTATUS' ).

CASE ls_column-id.

WHEN 'EXPIRYSTATUS'.

ENDCASE.

ENDLOOP.

Former Member
0 Kudos

I did it using the set_tooltip_fieldname method.

Thanks for the help.

regards,

Priyank

Former Member
0 Kudos

Hi Pri,

In which class, did you find this method?

BR,

Peter

Answers (1)

Answers (1)

ChandraMahajan
Active Contributor
0 Kudos

Hi,

Create v_string as attribute in Context of view. now using set attribute method set the value of v_string as per the traffic light icon value.

just bind the attribute v_string to the tooltip property of alv column.

So at run time it will take value...

Hope this will solve your problem....

Regards,

Chandra

(Award points if helpful)

Former Member
0 Kudos

Hi Chandra,

I think this method too will set the tooltip for the entire column whereas i want different tooltips for each row depending on the value of the column.

any further hints?

regards,

Priyank

0 Kudos

DATA lr_if_controller TYPE REF TO iwci_salv_wd_table.
DATA lr_cmdl            TYPE REF TO cl_salv_wd_config_table.
DATA lr_col               TYPE REF TO cl_salv_wd_column.

lr_if_controller = wd_this->wd_cpifc_alv_metadata( ).
lr_cmdl = lr_if_controller->get_model( ).
... 

lr_col = lr_cmdl->if_salv_wd_column_settings~get_column( 'FACTORY_TYPE_EXT' ).
lr_col->get_cell_editor( )->set_tooltip_fieldname( 'FACTORY_TYPE_EXT_TOOLTIP' ).

FACTORY_TYPE_EXT_TOOLTIP is a hidden column, containing the tool tip for column FACTORY_TYPE_EXT