ReferenceField持续显示空值的加载栏

时间:2018-02-11 08:37:53

标签: admin-on-rest

我在Listcustomerid之后有technicianid个组件 ReferenceField。有时我technicianidnull。因此UI不断显示加载栏(如下图所示)。

问题: 如何告诉ReferenceField处理null并只显示空字符串。

export const AppointmentList = (props) => (
    <List title="All Appointments" {...props}>
        <Datagrid>
            <ReferenceField source="customerid" reference="customers" label="Customer" >
                <TextField source="name" />
            </ReferenceField>
            <TextField source="name" label="Name" />
            <DateField source="scheduleddt" label="Schedule Date" />
            <ReferenceField source="technicianid" reference="technicians" label="Technician" >
                <TextField source="name" />
            </ReferenceField>
            <DateField source="createddatetime" label="Created" />
        </Datagrid>
    </List>
);

enter image description here

2 个答案:

答案 0 :(得分:2)

您需要'allowEmpty'属性。

export const AppointmentList = (props) => (
    <List title="All Appointments" {...props}>
        <Datagrid>
            <ReferenceField source="customerid" reference="customers" label="Customer" >
                <TextField source="name" />
            </ReferenceField>
            <TextField source="name" label="Name" />
            <DateField source="scheduleddt" label="Schedule Date" />
            <ReferenceField source="technicianid" reference="technicians" label="Technician" allowEmpty>
                <TextField source="name" />
            </ReferenceField>
            <DateField source="createddatetime" label="Created" />
        </Datagrid>
    </List>
);

https://marmelab.com/admin-on-rest/Inputs.html#referenceinput

答案 1 :(得分:0)

我们目前正在努力:)