bryntum / support

An issues-only repository for the Bryntum project management component suite which includes powerful Grid, Scheduler, Calendar, Kanban Task Board and Gantt chart components all built in pure JS / CSS / TypeScript
https://www.bryntum.com
54 stars 6 forks source link

Error when customizing AjaxStore's encodeSorterParams #10116

Open marciogurka opened 1 month ago

marciogurka commented 1 month ago

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.

sys0pp commented 1 month ago

encodeFilterParams may have the same issue

isglass commented 1 month ago

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