I would like to have the option to show a bunch of records, for example in Listview or Portal. Per record, I would like to add a button of an image, but based on content of the record (for example the status field) enable/disable the button, maybe show a different label of the button, or, in the case of an image, show different images, based on the content of the record (for example show different color trafficlights)
Currently, I do not know a way to do this (please correct me if I’m wrong… )
Also, the same sort of thing I would like to do with valuelists attached to a combo box. Let me give an example of where this comes in handy:
I’m in the proces of building a report generator. The reports can be flat data or a graph. secondly, some have specific time intervals in which the report can be run. Now, I display the available reports in a dropdown list of a combo box. What I would like to add in front of the report name is a clock image if the report can only run during a specific time interval and also add a graph image if the report is of type = Graph.
Maarten and Johan brought it to my attention a few weeks ago that we can already add graphics or other properties like color etc. to data in any view. You can use a calculated field with html in it. You would then use something like (in htis case changing font, color and size):
Status = ‘’ + Status + ‘’.
Offcourse you can also use this to attach a picture…
I had to fiddle around with it a bit, but got it working in the end: for all that want to try it, here’s some code. Place this code in the Calculation Area of a calculated field (of return type= media). Then place a field or label into, for example, your listview and attach the calculated field to it. If using a field, make sure it’s of type = HTML.
if(status==1)
{
return ‘’
}
else
{
return ‘’
}
Take care: the names of your images are case sensitive…
As for having a picture in the drop down of the combo, I figured out the following…
If you make a valuelist with custom values and then enter the following, in the dropdown you will see the picture!!!
|1
The |1 part is what will be returned into the field onto which you attach the combobox, which displays the valuelist. Now the sad part is… once you select the needed entry from the dropdown list, the picture disappears from the field and you see the HTML code again
Now, you clcik on the combo box, the list appears with the pictures and the text. Now, if I scroll up and down with my mouse, all text disappears on scrolling down and comes ack when I scroll up again.
If I browse through the dropdown with my cursor keys, then, when previeously having selected an item allready, when passing over the allready selected item in the dropdownlist, the text disappears, when scrolling up again the text shows again, only now it white, but in black.
Looks like some kind of bug to me..
Working on windows XP, latest RC, java 1.4.2 and standard LAF
Paul
PS: Any tip on how to line out the text under eachother would b appreciated…
Just dop this code in a custom valuelist and attach it to a combo box type of field.
This gets you a drop down list with images, where the image is the first column and the text is the second column. The images are centered in their column and the Text is nicely left aligned, under eachother.
So, when the disappear bug is fixed in RC5, you can have yourself a nice fancy combobox