Display a grid column as an image but sort based on a number?
Suppose I have a column named 'count' which stores, well, the count of something. I don't want to display the actual count -- I want to display an exclamation point image if the count is greater than some threshold. If the count is less than this threshold, nothing should be displayed in the cell. However, when I sort based on this column, I *do* want to use the real count to order the rows.
I've tried stuffing the text inside a hidden <span> in the cell and using AW.Formats.HTML, but that doesn't work because then the sorting is string-based and not numeric. I've tried using AW.Formats.Number, but then I don't get any sorting at all (I assume because it's trying to interpret the cell content as a number when it's actually an <img> tag).
I've been able to stick an image into a cell based on the count (in which case the sort is essentially based on whether the image exists or not). I've been able to sort based on the count itself (if I store the count in the cell -- in which case I don't have the image). I haven't yet figured out how to tie the two of these together.
I think perhaps a custom AW.Format class that combined AW.Formats.HTML & AW.Formats.Number might do the trick, but if there's an easier way that didn't require patching the code I'd rather do that.
I have a status for each row: red, orange, green.
Each status is represented by a number: 1,2,3
In the data for the table, the numbers are inserted.
But then i change the template of the column which should display the status to AW.Templates.Image like this:
Then I do a loop over all rows and set the image based on the data of the cell:
(depending on the data for this cell)
Then you can still set any sort order using cell/value property obj.setCellValue(...).
This topic is archived.
Back to support forum
Version 2Looking for AW 2.6 ?
The old site is here.