【问题标题】:Best way to edit a nested protobuf field in react-admin?在 react-admin 中编辑嵌套 protobuf 字段的最佳方法?
【发布时间】:2018-08-08 07:26:10
【问题描述】:

对于我们的管理页面,我们使用的是基本的

<SimpleForm>
  <TextInput>
  ...
</SimpleForm>

模式。

然而,我们的一个字段是嵌套的 protobuf 对象。虽然它是嵌套的,但这个 protobuf 对象的大部分字段都是相当基本的。我尝试使用像

这样的点表示法
<TextInput
  label="nestedField"
  source="ProtobufObject.nestedField"
/>

但这似乎不起作用。除了创建自定义输入之外,还有没有更直接的处理方式?

【问题讨论】:

    标签: react-admin


    【解决方案1】:

    除了我刚刚在谷歌网站上读到的内容之外,我对 ProtobufObject 一无所知。我有一个在下面返回 JSON 的 api。要显示事件名称,source="event.eventName"。如果您的有效负载不是 JSON,您需要在数据提供程序中对其进行转换。

    [
      {
        "competitionName": "XYZ",
        "competitionStatus": "SCHEDULED",
        "id": 107,
        "createdAt": "2018-08-30T03:53:37.000Z",
        "updatedAt": "2018-08-30T03:53:37.000Z",
        "event": {
          "eventName": "XYZ",
          "eventDesc": "Something",
          "startDate": "2018-09-13T07:00:00.000Z",
          "startTime": "2018-08-30T01:00:58.482Z",
          "endTime": "2018-08-30T03:00:58.484Z",
          "eventLocation": "Gym",
          "competitionId": 107,
          "createdAt": "2018-08-30T03:53:37.000Z",
          "updatedAt": "2018-08-30T03:53:37.000Z",
        }
      }
    ]
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2014-05-15
      • 2018-02-17
      • 2023-01-09
      • 2019-09-12
      • 2020-05-18
      • 1970-01-01
      • 2010-10-05
      相关资源
      最近更新 更多