Can I use the antD useTable with a resource or endpoint that is essentially custom?

Hi guys, wondering if i'm going about this the wrong way and could use some advice / help if possible. for eg. i want to do something like this and make a table that disaplys and filters custom data export const ForwardPackProjectionTable: React.FC<{}> = () => { const { tableProps: projectionTableProps, tableQueryResult, searchFormProps, } = useTable< IPackProjection, HttpError, ForwardPackProjectionFilterVariables >({ resource: subscriptions/project, initialPageSize: 100, onSearch: (params) => { const filters: CrudFilters = []; const { packName, month } = params; console.log("params", params); console.log("masterPack", packName); filters.push({ field: "packName", operator: "eq", value: packName, }); console.log("month", month); filters.push({ field: "month", operator: "eq", value: month, }); console.log("filters", filters); return filters; }, }); where subscriptions/project returns an array of objects, that's to say that it isn;t a List, or Show or something wired in like that
24 Replies
sensitive-blue
sensitive-blue2y ago
Hey @ben_g., Can you clarify what you mean by "custom data"? Are you trying to display data that is not in the response from the API?
sensitive-blue
sensitive-blue2y ago
hey @salihozdemir thanks for your response. Im not using an endpoint mapped in the strapi api (as in the mode). Other than that i am using the data or attempting to as it is returned
sensitive-blue
sensitive-blue2y ago
No description
sensitive-blue
sensitive-blue2y ago
No description
sensitive-blue
sensitive-blue2y ago
so when normally would use a table i would target for example /subscriptions which would have a content type in strapi. this time im simply trying to get an array of objects (with types) into a table and then filter it
sensitive-blue
sensitive-blue2y ago
I'm not sure, but Strapi doesn't support filtering array fields.
sensitive-blue
sensitive-blue2y ago
hmm ok thanks hey @salihozdemir it's not an array issue i have another example of a table where the data being returned from strapi is an array of objects
sensitive-blue
sensitive-blue2y ago
No description
sensitive-blue
sensitive-blue2y ago
No description
Omer
Omer2y ago
Hey @ben_g. , We didn't fully understand your question. Could you please share more details with us?
sensitive-blue
sensitive-blue2y ago
Hey @Omer for sure!, so i have in the past used the regular useTable to display data from resources and filter them no problem. But those resources or endpoints are named in the resources array in the App.tsx, whereas this time im simply wiring the resource to an endpoint i created in my CMS (strapi) that isn't named in the App.tsx
No description
sensitive-blue
sensitive-blue2y ago
appreciate your help guys! in my project, subscriptions exists in the App.tsx
sensitive-blue
sensitive-blue2y ago
and the table and filtering works no problem
No description
sensitive-blue
sensitive-blue2y ago
However the subscription is a content type on strapi, wheras subscriptions/project is simply an endpoint that returns an array of objects.... the data could be any shape (as long as its typed) my question is can i hook up the useTable to an endpoint like /project where the data can be any shape and filter that table ? also, im not sure if im confusing everyone by thinking that the resource being named in the App.tsx is a thing
sensitive-blue
sensitive-blue2y ago
Hello @ben_g. , so from what I understand, you have a strapi resource named subscriptions/projects, where projects can be in any shape, and you want to list subscriptions/project content type data without creating resource. Did I get it right?