support icon indicating copy to clipboard operation
support copied to clipboard

Error when customizing AjaxStore's encodeSorterParams

Open marciogurka opened this issue 1 year ago • 2 comments

Forum post

"With the code below I'm unable to run a build "npm run build". Is there a different approach to defining a custom sort encoder that can send params to the API? I will have the same question for encodeFilterParams as I'll need to modify params for filtering also.

It gives the error:

"Object literal may only specify known properties, and 'encodeSorterParams' does not exist in type 'AjaxStoreConfig'." "

Add to a Typescript (can be the React-Vite one) the following piece of code

new AjaxStore({
        readUrl: `/api/accounts`,
        autoLoad: true,
        pageParamName: "page",
        sortParamName: "sort",
        filterParamName: "filter",
        responseDataProperty: "data",
        responseTotalProperty: "total",
        encodeSorterParams: (sorters: any[]) => {
          return sorters.map((sorter: any) => JSON.stringify({
            property: sorter.field,
            direction: sorter.ascending ? 'asc' : 'desc'
          }));
        },
      })

It should allow overriding encodeSorterParams, but it gives the error that the user is mentioned.

marciogurka avatar Sep 24 '24 20:09 marciogurka

encodeFilterParams may have the same issue

sys0pp avatar Sep 25 '24 15:09 sys0pp

Probably need to document it as a config if it is intended to be overridden , for it to appear correctly in typings

isglass avatar Oct 02 '24 06:10 isglass