【问题标题】:Column not showing data using Gridjs while integrating with React js与 React js 集成时,列未使用 Gridjs 显示数据
【发布时间】:2021-01-08 07:51:55
【问题描述】:

目前我正在使用 Gridjs 在我的 Reactjs 应用程序中显示我的表格。

这是代码,NameEmail 显示正确,但 created_at 不正确,给我空白。如何显示数据?谢谢你。。

【问题讨论】:

    标签: reactjs html-table datatable datafield gridjs


    【解决方案1】:

    如果您使用 JSON 输入,则需要为您的列定义一个自定义 id

    例子:

    const grid = new Grid({
      columns: [{
         id: 'name',
         name: 'Name'
      }, {
         id: 'email',
         name: 'Email'
      }, {
         id: 'phoneNumber',
         name: 'Phone Number'
      }],
      data: [
        { name: 'John', email: 'john@example.com', phoneNumber: '(353) 01 222 3333' },
        { name: 'Mark', email: 'mark@gmail.com', phoneNumber: '(01) 22 888 4444' },
      ]
    });
    

    https://gridjs.io/docs/examples/import-json/

    【讨论】:

    • 细说一下,“columns”中key id的value需要和“data”中key的name相同.
    猜你喜欢
    • 1970-01-01
    • 2022-01-05
    • 2021-01-31
    • 1970-01-01
    • 2019-12-25
    • 2020-02-17
    • 1970-01-01
    • 1970-01-01
    • 2021-11-16
    相关资源
    最近更新 更多