cancel
Showing results for 
Search instead for 
Did you mean: 

Showing Image in table

Former Member
0 Kudos

Hi

I want to show image in table based on the result i have a field status which contains the 01 / 02 / 03 values and now i want to show 3 images insted of value I have created one value attribute of string type and assigned the path of the image to it but its taking the image of last record only so can any one tell me what i have to do for this bellow is the code i am using

wdContext.currentContextElement().setImgXiStatus("");
if(xistatus.equals("01"))
{
    wdContext.currentContextElement().setImgXiStatus("green.bmp");
}
else if(xistatus.equals("02"))
{
    wdContext.currentContextElement().setImgXiStatus("yellow.bmp");
}
else if(xistatus.equals("03"))
{
    wdContext.currentContextElement().setImgXiStatus("red.bmp");
}
else
{
    wdContext.currentContextElement().setImgXiStatus("");
}

Thanks

Ninad

Accepted Solutions (0)

Answers (3)

Answers (3)

Former Member
0 Kudos

I would add a (read-only) <b>calculated </b> attribute "Icon" (string) under the table data source node.

If you cannot add attributes under this node (because it has a structure binding), you can add a helper value node (cardinality 1:1, selection 1:1, singleton=false) and add the "Icon" attribute there.

Implement the get-method like this:

String getIcon(I<Node>Element element)
{
  if ("01".equals(element.getXiStatus())
  {
    return "green.bmp";
  }
  else if ("02".equals(element.getXiStatus())
  {
    return "yellow.bmp";
  }
  else if ("03".equals(element.getXiStatus())
  {
    return "red.bmp";
  }
  else
  {
    return "";
  }
}

Armin

Former Member
0 Kudos

Hi Ninad,

Make the value attribute a part of the node that is the datsource of your table. If you create the value attribute as a part of your context root node, then all rows in the table will share the same value.

Regards,

Satyajit.

Former Member
0 Kudos

The problem is with your context structure..You are having only one element as you have created the attribute directly under root conext.

If the table datasource is bound to a model node then,create a helper node (value node cardinality-1:1, singleton-false)under the node that is bound to your table datasource and place your value attribute <i>ImgXiStatus </i>under the newly created helper node. Finally modify your code accordingly.

If the table datasource is bound to a value node, then simply put your value attribute <i>ImgXiStatus </i>under the value node.

Bala

Message was edited by: Bala Krishnan

Former Member
0 Kudos

Hi Bala

I am not getting what is helper value node can you please explane me what exactly it is or how do i create it? in in my context i can create only value node or model node is there any other method i have to follow?

Thanks

Ninad

Former Member
0 Kudos

Such a helper node (value node) is only needed, if you cannot directly add attributes to the data source node of the table. See my answer in this thread.

Armin

Former Member
0 Kudos

Hi Armin

i have seen it but i don't know how to create the helper node is it the third type of node other than valu and model or some thing else? and how to specify cardinality?

thanks

Ninad

Former Member
0 Kudos

First, try to add the attribute directly to the table's data source node.

Only if this is not possible, add a <b>value node</b> as described. Use a value node with cardinality=1:1 and selection=1:1 (I already wrote this above).

Armin

hadar_morchi
Participant
0 Kudos

Hi Armin,

As a flow up to this Thread...

I want to show/hide an image base on data that is in attribute [structure binding attribute ...]

So... I took your suggestion and implemented it..

My question is:

How can I, from the "get-method" refer to this attribute?

example:

My context looks like this:

1 - NODE_MY_TRNAS

1.1---NODEoutput

1.1.1---NODEetData

1.1.1.1---NODEimageNodeHelper

1.1.1.1.1---icon

1.1.1.2---attribute1[how can i get to this atytribute in the code]

1.1.1.3---attribute2

1.1.1.4---attribute3

Hope i'm understood...

10x hadar

Former Member
0 Kudos

Assuming "NODEetData" and its parent nodes are singleton, you can use

wdContext.currentNODEetDataElement().getAttribute1()

Armin

hadar_morchi
Participant
0 Kudos

hi Armin,

tried this ... my problem is that works only for the first row of the table ....

any idea why ?

just to be clear ,

both NODE_MY_TRNAS ,NODEoutput, NODEetData as well as Attribute1, Attribute2 etc are structure binding .

Hadar

Former Member
0 Kudos

What about the assumption I mentioned?

Armin

Former Member
0 Kudos

Hi Ninad,

Helper value node is nothing but a <b>Value Node</b>. Once you creare a value node go to the properties there you will find the properties: Cardinality and Singleton. Set those properties as suggested by Bala, which solves your problem.

Regards,

Jhansi

hadar_morchi
Participant
0 Kudos

Hi Armin,

The assumption u made was right [all singleton]....but ... it didn't work for me.

[As I wrote earlier ... ]

Finally, I did what u suggests but a little different, i used a supply function and it works ok.

Thanx a lot

Hadar

Former Member
0 Kudos

1 - NODE_MY_TRNAS

1.1---NODEoutput

1.1.1---NODEetData

1.1.1.1---NODEimageNodeHelper

1.1.1.1.1---icon

Set singleton = false for node "NODEimageNodeHelper" and selection(NODEimageNodeHelper) = 1:1.

Assuming card(NODEetData) =0:N, you can set the icon for row number i as follows:

INODEetDataElement e = wdContext.nodeNODEetData().getNODEetDataElementAt(i);
e.nodeNODEimageNodeHelper().currentNODEimageNodeHelperElement().setIcon("icon.gif");

For naming nodes, the following rule is useful: Name in camel-case, first letter uppercase, for cardinality =0:N, use plural name.

Example:

Node "Books" (node, card=0:N) leads to IBooksNode, IBooksElement interfaces.

Armin