I am trying to highlight a row upon condition in a table. Am using Jqxgrid and did something in the front-end to highlight:
TypeScript:
carsDataAgain = [
{
year: '1967',
make: 'Pontiac',
model: 'GTO',
id: '1002',
},
];
getCarsData(val: string) {
//console.log(model);
if (this.carsDataAgain.find((i) => i.model === val.model)) {
return 'Matched';
} else {
return 'Unmatched';
}
}
HTML:
<jqxGrid
[theme]="'material'"
[width]="getWidth()"
[source]="hello"
[columns]="columns"
[pageable]="true"
[autoheight]="true"
[sortable]="true"
[selectionmode]="'singlerow'"
[altrows]="true"
[enabletooltips]="true"
[editable]="true"
[filterable]="'true'"
[columngroups]="columngroups"
[keyboardnavigation]="'false'"
enablekeyboarddelete="false"
[ngClass]="{
primary: getCarsData(hello) === 'Matched',
secondary: getCarsData(hello) === 'Unmatched'
}"
>
</jqxGrid>
In the front-end, I did something as follows using ngClass:
[ngClass]="{
'primary': getCarsData(hello) === 'Matched',
'secondary': getCarsData(hello) === 'Unmatched'
}"
So what am doing, passed the data source in the method and checked the returned value to highlight. In my end, am verifying if there's an existing model (GTO) in the carsDataAgain array, then highlight. As there's a matching model, then it should highlight the first row. Here's a sample that I tried so far: Highlight A Row
Is there any other way to implement it or am I missing something here?