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
absent-sapphire
absent-sapphire2y 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?
foreign-sapphire
foreign-sapphire2y 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
foreign-sapphire
foreign-sapphire2y ago
No description
foreign-sapphire
foreign-sapphire2y ago
No description
foreign-sapphire
foreign-sapphire2y 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
absent-sapphire
absent-sapphire2y ago
I'm not sure, but Strapi doesn't support filtering array fields.
foreign-sapphire
foreign-sapphire2y 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
foreign-sapphire
foreign-sapphire2y ago
No description
foreign-sapphire
foreign-sapphire2y ago
No description
Omer
Omer2y ago
Hey @ben_g. , We didn't fully understand your question. Could you please share more details with us?
foreign-sapphire
foreign-sapphire2y 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
foreign-sapphire
foreign-sapphire2y ago
appreciate your help guys! in my project, subscriptions exists in the App.tsx
foreign-sapphire
foreign-sapphire2y ago
and the table and filtering works no problem
No description
foreign-sapphire
foreign-sapphire2y 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
rare-sapphire
rare-sapphire2y 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?
foreign-sapphire
foreign-sapphire2y ago
Hi @batuhanw ! yeah close subscriptions/project where i am projecting the amount of subscriptions that are in future months. Im not (or wasn;t)going to create an actual content type to track this in strapi. my projection data looks like this. When i said the data could be any shape i meant that there is no type expectation on this endpoint from the CMS point of view. I can;t for example use the strapi service.find etc
No description
foreign-sapphire
foreign-sapphire2y ago
i put the data i require into an object like this an send it over the wire data = [{ packName: sku.packName, pricePoint: sku.price, masterSku: sku.sku, expectedQty: [ { date: "2022-08-01", qty: 0 }, { date: "2022-09-01", qty: 0 }, { date: "2022-10-01", qty: 0 }, { date: "2022-11-01", qty: 0 }, ], }]
rare-sapphire
rare-sapphire2y ago
So, do you want to list data in the expectedQty in the table column?
foreign-sapphire
foreign-sapphire2y ago
currently i can list it, i just can;t filter it one moment
foreign-sapphire
foreign-sapphire2y ago
@batuhanw so i have this on the front end
No description
foreign-sapphire
foreign-sapphire2y ago
but i want to know if i can;t filter the data becuase im a dumbass, or if there is some issue with the data jsut coming from any old endpoint and not the App.tsx endpoint
rare-sapphire
rare-sapphire2y ago
@ben_g. I'm afraid this question isn't directly related to refine. If you think this is related to refine itself, please add some details - resource name - filters - example query - expected response If not, you can try to check how you can send nested filters for strapi (If it exists) Or you can explore how to do client side filter on antd table. Best
foreign-sapphire
foreign-sapphire2y ago
thanks @batuhanw for your time, appreciate it. 🫡
rare-sapphire
rare-sapphire2y ago
We appreciate your time @ben_g., thanks 🙏