在 Remix 中获取 ag-grid 的数据
我正在学习 Remix.run 并试图找出如何面对一些要求 提前。根据文档,有一个名为 资源路由 的东西。但似乎资源路由需要从链接组件链接:
<Link to="pdf" reloadDocument>
View as PDF
</Link>
我找不到任何示例来展示如何创建可以返回网格组件数据的简单路由,例如 ag-grid 。
有什么方法可以在 Remix 中执行此操作,或者我需要实现外部端点?
I'm learning Remix.run and trying to figure out how to face some requirements
in advance. According to the documentation there is something called Resource Routes. But seems that a Resource Route
need to be linked from a Link component:
<Link to="pdf" reloadDocument>
View as PDF
</Link>
I can't found any example showing how to create a simple route that can return data for a grid component, for example ag-grid.
There is any way to do this inside Remix or I will need to implement an external endpoint?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
AG Grid 不久前写了一篇关于此的博客文章。这是文章: https:// blog.ag-grid.com/using-ag-grid-react-ui-with-remix-run/。
首先,使用此处概述的 Remix 约定设置资源路由: https://remix.run/docs/en/v1/guides/resource-routes#creating-resource-routes
资源路由应该只导出一个加载器函数来检索您想要的数据加载到表中。
注意:此示例还使用无限滚动的逻辑
app/routes/posts/$id/postsGridData.ts
接下来,在包含 AGGridReact 组件的路由中,您将添加以下内容:
onGridReady
函数,用于加载下一批数据datasource
代码>插入 AG GridrowModelType
和onGridReady
app/routes 的 AgGridReact 组件时触发的
useEffect
函数/posts.tsxAG Grid wrote a blog post about this not too long ago. Here is the article: https://blog.ag-grid.com/using-ag-grid-react-ui-with-remix-run/.
First, set up a resource route using Remix's conventions outlined here: https://remix.run/docs/en/v1/guides/resource-routes#creating-resource-routes
The resource route should export only a loader function that retrieves the data you want to load into the table.
Note: This example also uses logic for infinite scrolling
app/routes/posts/$id/postsGridData.ts
Next, in the route with your AGGridReact component, you'll add the following:
onGridReady
function that loads the next batch of datadatasource
to plug into AG GriduseEffect
function to trigger when the fetcher has loadedrowModelType
andonGridReady
app/routes/posts.tsx