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 that24 Replies
sensitive-blue•2y 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•2y 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•2y ago
![No description](https://cdn.answeroverflow.com/1077173921943650364/image.png)
sensitive-blue•2y ago
![No description](https://cdn.answeroverflow.com/1077174131914715166/image.png)
sensitive-blue•2y 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•2y ago
I'm not sure, but Strapi doesn't support filtering array fields.
sensitive-blue•2y 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•2y ago
![No description](https://cdn.answeroverflow.com/1077189411864842320/image.png)
sensitive-blue•2y ago
![No description](https://cdn.answeroverflow.com/1077189455129088100/image.png)
Hey @ben_g. ,
We didn't fully understand your question. Could you please share more details with us?
sensitive-blue•2y 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](https://cdn.answeroverflow.com/1077191539207446578/image.png)
sensitive-blue•2y ago
appreciate your help guys!
in my project, subscriptions exists in the App.tsx
sensitive-blue•2y ago
and the table and filtering works no problem
![No description](https://cdn.answeroverflow.com/1077192308023382087/image.png)
sensitive-blue•2y 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•2y 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?