Answer 2 is correct, but the syntax used is incorrect and caused several problems related to its sorting. For example, try to minimize the response of 2 codes. This did work, but it is not the correct syntax as far as I can see.
Please note: this can be done inline or with an external function, 2 different ways:
SEPARATE FUNCTION:
vm.gridOptions = { columnDefs: columnDefs, getRowStyle: getRowStyleScheduled } function getRowStyleScheduled(params) { if (params.selected && params.data.status === 'SCHEDULED') { return { 'background-color': '#455A64', 'color': '#9AA3A8' } } else if (params.data.status === 'SCHEDULED') { return { 'background-color': '#4CAF50', 'color': '#F4F8F5' }; } return null; };
INLINE:
vm.gridOptions = { columnDefs: columnDefs, getRowStyle: function(params) { if (params.selected && params.data.status === 'SCHEDULED') { return { 'background-color': '#455A64', 'color': '#9AA3A8' }; } else if (params.data.status === 'SCHEDULED') { return { 'background-color': '#4CAF50', 'color': '#F4F8F5' }; } return null; } }
source share