Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
2585
igGrid Group by not ignoring Time
posted

We have a grid column that is display date in M/DD/YYYY format. The Data set for this date column includes a time value. When the user groups by this column the grouping is including the time so there are many groups for the same date. Is there a way to tell the grid to ignore the time for the grouping? I would have assumed it would grouped based on the format displayed to the user but its not working that way.

Parents
  • 23953
    Offline posted

    Hello Tammy,

     

    Let me explain why this is the case.

    The GroupBy is a data operation (data operations like GroupBy, Sorting, Filtering and Paging) that's executed at igDataSource level so it's not affected by the formatting (formatting is done before displaying the data) which is done on igGrid level. Currently we don't have formatting capabilities in igDataSource, that's why what you expect is not currently available out of the box.

    To cover your scenario we expose an option igGridGroupBy.columnSettings.compareFunc that you need to set with custom logic.

    Here's a sample implementation that compares only the dates:

    features: [

    {

    name: "GroupBy",

    columnSettings: [

    {

    columnKey: "SellStartDate",

    compareFunc: function(val1, val2, recordsData) {

    var d1 = new Date(val1), d2 = new Date(val2);

    return d1.getYear() === d2.getYear()

    && d1.getMonth() === d2.getMonth()

    && d1.getDay() === d2.getDay();

    }

    }

    ]

    }

    ]

     

    Best regards,
    Martin Pavlov

    Infragistics, Inc.

Reply Children