on 03-03-2010 8:41 PM
I have a grid applet that has a column whose background color depends on the value of the cell. The table is a list of 'Groups' and each group has a color attribute, for example, the table might look like this. So for each table row there will be a corresponding color context row.
Group Color
Group 1 #FFFFFF
Group 2 #FF0000
Group 3 #00FF00
The user can set the color for each group. Anytime an update is made to the grid, code is executed to setMatchColors, and setMatchValues (which are the same) to the current color values represented.
Anyway, the code and page work fine in general. However if 17 or more groups are displayed, it breaks this routine and no colors are applied to the column. 1 group through 16 groups, works flawlessly. Is there some unseen limitation to the number of match rows that can be contained in the displaytemplate?
I put in some debug to return the colors and values using getMatchColors and getMatchValues, and all seems fine.
Thanks,
Rod
I managed to recreate your problem in 12.0.9, up to 16 works fine, after that no colours are displayed. Raise it as a SAP note.
A workaround could be to check the length of the setting, and if it exceeds 16 use javascript to colour the cells.
Something like this
aColours = oGrid.getMatchColors().split(",")
if (aColors.length>16) {
aValues=oGrid.getMatchValues().split(",")
for (rowOn=1; rowOn<=oGrid.getRowCount(); rowOn++)
cellVal=oGrid.getCellValue(rowOn, 1)
for (colour=0; colour<aColours.length; colour++) {
if (cellVal==aValues[colour]) {
oGrid.setCellBackgroundColorAsString(rowOn,1,aColours[color])
break
}
}
}
}
Hope this helps
Nick
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Jeremy,
I'm not using workbench except to set the color match column. I double checked the strings to ensure I had no spaces, getMatchValues would return the expected 135 characters with 17 color values (127 with 16).
Nick,
Thanks a bunch, I abandoned the color contexting and instead set the background color for the cells each time the grid is updated. The only issue I ran into was that sometimes the colors would not show up until a row of the applet was clicked, however the behavior was inconsistent. Although not pretty, I ended up adding code to select and deselect a row after the grid is updated, and that seems to do the trick.
if(acGetColors.executeCommand()) {
document.agMaterialGroup.updateGrid(true);
iRows = acGetColors.getRowCount();
for(var x = 1; x <= iRows; x++) {
sColor = acGetColors.getValue(giColorColumn,x);
oagMaterialGroups.setCellBackgroundColorAsString(x,6,sColor);
}
document.agMaterialGroup.setSelectionEventEnabled(false);
oagMaterialGroups.setSelectedRow(1);
oagMaterialGroups.deselectAllRows();
document.agMaterialGroup.setSelectionEventEnabled(true);
}
The last four lines, shouldn't be required, but I won't lose any sleep.
Thanks,
Rod
Did you log a support ticket? I made a quick sample for this in 12.0 (saw same problem) and ported it into 12.1+ and with the color contexting changes everything worked the way you initially setup your grid.
If you create the ticket I'll add my templates into it and they can fix this in the next SP or patch for 12.0.
Thanks Jeremy,
Don't mind progressing this for the greater good.
For what I am doing where the hex color value itself is stored in the database, Nicks solution is a bit more efficient (fewer calls to the server), except for the kluggy(sp?) way I had to make the color appear by selecting and deselecting a row.
I hope to move to 12.1 this year.
Regards,
Rod
16 would seem to be a magic number of sorts, but these parameters are comma separated lists, not indexed properties like TagName.x or Param.x, which do have a fixed range.
Have you tried sorting your grid DESC with the same match attributes? Does it still only do the first 16 rows?
Some of the earlier revs of the 12.0 workbench did have issues configuring the color contexting parameters in the layout table, but if you've confirmed the comma separated lists then I don't see why it shouldn't work the way you expect.
Make sure there are no spaces after your commas, and you don't shortchange or invalidate any of the color strings.
Also make sure your "Group 1" column data doesn't have trailing spaces like "Group 1 ".
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
11 | |
6 | |
2 | |
1 | |
1 | |
1 | |
1 | |
1 | |
1 | |
1 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.