Skip to content

Custom color for a cell in data grid #596

Closed Answered by nzbin
rahulpd101 asked this question in Q&A
Discussion options

You must be logged in to vote

https://ng-matero.github.io/extensions/components/grid/overview#custom-class-for-row-and-column

  columns: MtxGridColumn[] = [
    { header: 'ID', field: 'id' },
    { header: 'name', field: 'name' },
    {
      header: 'weight',
      field: 'weight',
      class: (data) => {
        return data?.weight > 10 ? 'danger' : data?.weight > 5 ? 'warning' : '';
      },
    },
    {
      header: 'gender',
      field: 'gender',
      class: (data) => {
        return data?.gender === 'male' ? 'info' : '';
      },
    },
    { header: 'mobile', field: 'mobile' },
  ];

Replies: 1 comment

Comment options

You must be logged in to vote
0 replies
Answer selected by rahulpd101
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants