UI table formatter If Else creates broken sort

Hello, if I use the following If Else statement in my msg.ui_control I get the expected result but the table is broken and doesn't display all the rows and is only able to sort in one direction. The other direction creates a blank table.

            {
                "title": "State",
                "field": "collectionState",
                "formatter": "function(cell, formatterParams, onRendered){var value = cell.getValue();if(value.includes('Normal')){return `<span style='color:#3FB449; font-weight:bold;'>` + value + `</span>`;}else {return `<span style='color:#ff0000; font-weight:bold;'>` + value + `</span>`;}}",
                "width": 100,
                "align": "center"
            },

Looks like I had some undefined values. Correct code is below:

            {
                "title": "State",
                "field": "collectionState",
                "formatter": "function(cell, formatterParams, onRendered){var value = cell.getValue();if (value !== undefined) {value = value}else {value = ' '};if(value.includes('Normal')){return `<span style='color:#3FB449; font-weight:bold;'>` + value + `</span>`;}else {return `<span style='color:#ff0000; font-weight:bold;'>` + value + `</span>`;}}",
                "width": 100,
                "align": "center"
            },

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.