0
votes

I am trying to row group dateTime column in ag-grid. Below are the steps in my project.

I have a column ProcessDate which has a value of format YYYY-MM-DDTHH:mm:ss. Once I get this value, I apply a formatter to convert this value into MM/DD/YYYY

  dateFormatter(params) {
    if (params.value) {
      return moment(params.value, ['YYYY-MM-DD', 'MM-DD-YYYY', 'MM/DD/YYYY', 'YYYY-MM-DDTHH:mm:ss'], true)
        .format('MM/DD/YYYY');
    }
  }

The problem is my view value is in format MM/DD/YYYY so when i try to rowgroup based on ProcessDate column, ag-grid does it using actual value (YYYY-MM-DDTHH:mm:ss format value) But not using view value (MM/DD/YYYY).

Can anyone help me how to row-group based on view value.

1

1 Answers

0
votes

Your valueFormatter is used to format the values for display, whereas you need a valueGetter which will be used when to retrieve the value when grouping.

Add this as valueGetter for your processDate column definition:

  valueGetter: function(params){
    if (params.data)
    {
      return moment(params.data.processDate).format("MM/DD/YYYY");;
    }
    return;
  }

Now when you group by processDate, the time will be irrelevant.

Demo.