cancel
Showing results for 
Search instead for 
Did you mean: 

Table column: different buttons (e.g. colours)

Former Member
0 Kudos

Hello everybody,

I am trying to set in a table column different buttons (attribute image-source).

The buttons text-attribute is linked to the context. I would like to set the image-souce attribute dynamicly?

How can I do that? How should the be?

Thanks a lot,

Regards Mario

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

Hi Mario,

As AnilKumar has pointed out, create a string attribute inside the node that you have bound to the table. Let the attribute's name be 'image_src' and let the node bound to the table be 'table_node'.

After creating the Button UI element in the table column, bind it's 'imageSource' property to this attribute.

Now in your code,when you create the elements of the table set the 'image_src' value accordingly (depending on the condition you want). Here I'm giving you an example where alternate rows have the same icon.

IPrivate<View_name>.I<node_name>Element elmt;

for(int i=0;i<n;i++)

{

elmt = wdContext.create<node_name>Element();

elmt.set<parameter>(<value>);

if((i%2)==0)

elmt.setButt_image("~sapicons/s_b_okye.gif");

else

elmt.setButt_image("~sapicons/s_b_okno.gif");

wdContext.node<node_name>().addElement(elmt);

}

This example make use of the default sap icons available in the server. If you need your own images on the button, you can store them in src->mimes->components-> <your component>.

Hope this helps,

Best Regards,

Nibu.

Former Member
0 Kudos

Hi Nibu,

thanks for your help. Unfortunately some things do not work:

a) elmt.set<parameter>(<value>);

--> What do you mean with <value> ? Which value should be there?

b) elmt.setButt_image("~sapicons/s_b_okye.gif");

--> I get an syntax error. setButt_image seems to be no method of elmt

Thanks and best regards, Mario

Former Member
0 Kudos

Hi Mario,

a) elmt.set<parameter>(<value>);

I was just giving you an example. If you have any other attribute in that node to set value for, you can set it there using the given syntax.

b) elmt.setButt_image("~sapicons/s_b_okye.gif");

I'm very sorry, the statement should have been

elmt.setImage_src("~sapicons/s_b_okye.gif"); // atleast in this example

where 'image_src' should be replaced by the attribute you created. In the given example, i just used the attribute's name as 'image_src'.

Best Regards,

Nibu.

Former Member
0 Kudos

Hi Nibu, very good!

Thank you much

Answers (2)

Answers (2)

Former Member
0 Kudos

You can create a valueAttribute and bid that to the Imagesource property in the way how you are doing for

text-attribute .

Regards, Anilkumar

Former Member
0 Kudos

How should the be?

--> How should the coding be?