SenyaMur / ag-grid-odata

Implementation Odata ServerSideDatasource for ag-grid
MIT License
19 stars 6 forks source link

Unable to group and expand data fields #51

Open janisvisma opened 3 months ago

janisvisma commented 3 months ago

Steps to Reproduce:

Create a dataset with date fields. Configure Ag-Grid to display the dataset, allowing grouping by date fields. Attempt to group the data by date. Group works as expected. Expand grouped row. Odata uses date to filter value as string (not a date type)

Expected Behavior: Odata filter uses date as intended. https://odatasampletest.azurewebsites.net/odata/Heroes?$count=true&$top=100&$filter=AddedOn eq 2024-03-28 Actual Behavior: When expand a grouped column (by date), Odata sends a request as grouped Date is a type of string. this triggers a backend error. https://odatasampletest.azurewebsites.net/odata/Heroes?$count=true&$top=100&$filter=AddedOn eq '2024-03-28'

I have attached a repo. for the following issue. Steps:

  1. Group by AddedOn column
  2. Expand Date column https://codesandbox.io/p/sandbox/stupefied-leaf-pycscc
SenyaMur commented 3 months ago

Hi, @janisvisma Thank you for your Issue!

I Add in new version v 1.0.33 new properties rowCustomFilter in OdataServerSideProvider.

Usage example

new OdataProvider({
        callApi: (options) =>
          fetch(
            `https://odatasampletest.azurewebsites.net/odata/Heroes${options}`,
            {
              headers: {
                "Content-type": "application/json",
                Accept: "application/json",
              },
            }
          ).then((resp) => resp.json()),
        beforeRequest: (query, provider) => {},
        afterLoadData: (options, rowData, totalCount) => {
          if (options.skip === 0 && rowData.length > 0) {
            params.columnApi.autoSizeAllColumns();
          }
        },
        rowCustomFilter: {
          AddedOn: (colName,value ) => {
            return `${colName} eq ${value}`};
          }
        }
      })

You can check it in this sandbox

Please, check it, and give me feedback.

janisvisma commented 3 months ago

Hi @SenyaMur, Thanks for quick response! I have tested your provided example and it works on our environment too. However, now the same problem occurs in pivot mode. Steps to repo:

  1. Enable Pivot mode.
  2. Select AddedOn
  3. Select Id
  4. Expand Row.