Resource without initial records
Hi there. I've the problem when trying to use AntdListInferencer to display the resource without records (as data supposed to be filled up from frontend firstly)... It shows me Error block with text of 'No records/data found for resource ....'. In generally it is understandable, because Inferencer doesn't know what columns should be shown. But is it feasible to pass this information and have it to show the table without records, and with empty row to create new record? Or at least 'intercept' Error block output and show Create button there instead of error? Or what is true 'refine' way to handle such cases?
Thanks.
4 Replies
Hi @vedariy. I'm kapa.ai, your friendly support bot. I will try to answer your question by searching through the knowledge base. :wave:
----------------------
Hmm, I don't know enough to give you a confident answer yet. However, I can provide some general guidance based on the information available.
The
AntdListInferencer
component in refine is designed to automatically generate a table view for your resources. It uses the resource schema to infer the columns and data to be displayed. If there are no records for a particular resource, it might display an error message.
To handle such cases, you might want to consider customizing the error message or providing a default view when no records are found. However, the specific implementation would depend on your application's requirements and the capabilities of the refine framework.
For more detailed guidance, you might want to refer to the refine documentation (https://refine.dev/docs) or ask for help in the refine Discord community (https://discord.com/channels/837692625737613362/).
----------------------
Note: you can ask me a follow up question by @ mentioning me again :speech_balloon:
----------------------<@891784748194742354> kapa.ai is still learning and improving, please let us know how it did by reacting below
ambitious-aquaOP•14mo ago
So is there way to force the resource schema for AntdListInferencer or what to set up a default view when no records found - is it possible to do on a data provider level or on ListPage presentation component level? Or where? Just in both ways - I couldn't find the approach to get rid of Error block as it is hidden inside of Refine.
compatible-crimson•14mo ago
Hello @vedariy Inferencer can only work when there is an API response and scaffolds some boilerplate code, you shouldn't rely on that for building your page, but can be used to get started easier. You can copy generated code into your page and start from there.