15
Views
2
Comments
Solved
[Data Grid Web] Get Cell Data only getting First Digit
Forge component by OutSystems R&D
41
Published on 14 Dec 2020
Application Type
Traditional Web

Hi All,

I'm having an issue when using the getCellData function in the data grid. I have copied how to change the cell color as per the demo but I'm am running into an issue comparing one cell's data against another. After applying this function it seems that when the two values are compared it is only taking the first digit of the number. For example I am trying to say if cell X < cell Y, color cell yellow however this is resulting in true when X = 21 and Y = 3. I was wondering if anyone else has had this issue or knows how to solve it, I have attached a snippet of the code I am using to color the cell. I have tried assigning the values to variables and comparing them that way but I cant seem to get it to work.

Any help is always appreciated!!

Thanks,

Bryan


    colorRenderer: function(panel, row, column, cell) {
        if (panel.cellType == wijmo.grid.CellType.Cell) { 
            var _class = '';
            
            if(wijmo.hasClass(cell, "Selected")) {wijmo.removeClass(cell, "Selected")};
            if(wijmo.hasClass(cell, "White")) {wijmo.removeClass(cell, "White")};

            if (panel.getCellData(row, column) < panel.getCellData(row, 14)) {
                _class = 'Yellow';
            }
            wijmo.addClass(cell, _class);
        }
Rank: #128
Solution

Hi Bryan,

I don't know this wijmo library, but my guess on first sight of your example would be that this comparison happens alphabetically ??

So in other words, the getCellData returns a string, so if you want to compare numerically, you'll have to first convert to a number.

Dorine

Rank: #3222

Thanks Dorine!!! By using parseInt() it is now comparing correctly