结构动态网格组件的最佳方法是什么?

发布于 2025-02-10 13:43:25 字数 825 浏览 3 评论 0原文

我正在构建一个Angular应用程序,其中大多数数据都显示在网格视图中。我想构建一个可重复使用的动态网格组件,该组件采用Config JSON对象并根据配置数据构建其新实例。

例如:

如果我想实现两个新网格(用户网格和报告网格),每个网格都有不同的行和col。他们俩都使用DynamicGrid组件。

我的问题: 对于性能明智,最好将网格的配置数据存储在数据库中还是将它们作为对象作为对象中的.TS文件中的编码?

类似的内容:

export const gridUserConfig:TableBasicConfig = {
colsLength: 7,
rowsLength: 100,
pagination: true,
rowsPerPage: [5, 10, 15, 50, 100, 200],
defaultRowsPerPage: 10,
style: {
  tableSizeClass: 'p-datatable-sm',
  gridLinesClass: 'p-datatable-gridlines',
  striped: 'p-datatable-striped'
},
header: {
  displayHeader: true,
  title: {
    displayTitle: true,
    text: 'User Grid'
  },
  caption: {
    displayCaption: true
  }
},
footer: {
  displayFooter: false
},
rawData: this.getUsers()

}

tablebasicConfig是指定响应的结构和键的接口。

I am building an angular app that the majority of the data is displayed in grid view. I want to build a reusable dynamic grid component that takes a config json object and build a new instance of it based on the config data.

For example:

If I want to implement two new grids (Users Grid and Report Grid) where each grid has different rows and cols. And both of them use the dynamicGrid component.

My question:
for performance wise, is it better to store the config data of the grids in the database or hardcode them in a .ts file as objects?

something like that:

export const gridUserConfig:TableBasicConfig = {
colsLength: 7,
rowsLength: 100,
pagination: true,
rowsPerPage: [5, 10, 15, 50, 100, 200],
defaultRowsPerPage: 10,
style: {
  tableSizeClass: 'p-datatable-sm',
  gridLinesClass: 'p-datatable-gridlines',
  striped: 'p-datatable-striped'
},
header: {
  displayHeader: true,
  title: {
    displayTitle: true,
    text: 'User Grid'
  },
  caption: {
    displayCaption: true
  }
},
footer: {
  displayFooter: false
},
rawData: this.getUsers()

}

TheTableBasicConfig is an interface where the structure and keys of the response are specified.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

五里雾 2025-02-17 13:43:25

在这种情况下,仅将数据存储在前端侧是一件好事,因为我们为不同类型的网格保存标准配置。

最好不要拨打不需要的API呼叫,在这里通过将配置放在前端侧,我们可以保存网络请求,并可以更快地为前端提供更好的用户体验。

但是,让我们考虑在某些情况下我们想要对每个网格的用户特定配置进行特定的配置,在这种情况下,将网格配置存储在数据库中总是好的,以便用户可以相应地自定义,我们可以将其保存到我们的数据库中用于将来的参考。

如果您想对此进行更多讨论,请随时发表评论。

谢谢。

In this case it is good to store the data on the frontend side only as we are saving standard configurations for the different type of Grids.

It is always good not to make unwanted API calls and here by putting the configurations on the frontend side, we can save the network request and can serve our frontend faster to better user experience.

But, let consider that there is a case where we want to have the user specific configuration for each Grid then in this case it is always good to store the Grids configuration into database so that user can customise accordingly and we can save it into our database for future references.

Please feel free to comment in case you want to discuss more on this.

Thanks.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文