React
Using ag-Grid with React: Rows

Custom Sorting

Outline

In this video, we learn how to use a custom comparator function to coerce the Amount column to be numbers instead of strings.

We can do this in the Amount column definition:

// App.js
// this.state column definitions
{
  headerName: "Amount",
  field: "amount",
  width: 140,
  comparator: (valueA, valueB) => {
     return +valueA - +valueB;
   },
},

Check out the ag-Grid docs on custom sorting to learn more.

 

I finished! On to the next chapter