TextField不会出现在“显示视图”中

问题描述 投票:0回答:1

我在Show视图中有一些TextField数据,我必须有条件地标记。我为此写了这个const:

const DataShow = ({record}) => {
    var label1, command;
    if ( parseInt(record.type) === 0 || parseInt(record.type) === 11 ) {
        label1 = "THM";
    }
    else if ( parseInt(record.type) === 21 ) {
        label1 = "Kártya típusa";
    }
    else if ( parseInt(record.type) === 26 ) {
        label1 = "EBKM";
    }
    else if ( parseInt(record.type) === 32 ) {
        label1 = "Számlavezetési díj";
    }
    else if ( parseInt(record.type) === 37 ) {
        label1 = "Minimum összeg";
    }
    else if ( parseInt(record.type) === 38 ) {
        label1 = "THM";
    }
    else if ( parseInt(record.type) === 47 ) {
        label1 = "Futamidő";
    }
    else {
        label1 = "";
    }
    command = <TextField source="data_1" label={label1} />;
    console.log("type: ", parseInt(record.type), "data_1: ", record.data_1, "label: ", label1, "command: ", command)
    return ( command );
};

我的问题是,即使我在控制台上找到调试信息,返回也不会出于某种原因(在我的Show视图中,Field根本没有出现)

我的展会代码:

export const AdShow = ({...props}) => (
    <Show {...props}>
        <TabbedShowLayout>
                <Tab label="summary">
                    <TextField label="Azonosito" source="id" />
                    <ReferenceField label="Hirdeto" source="user" reference="users">
                        <TextField source="name" />
                    </ReferenceField>
                    <TextField label="Termek Neve" source="title" />
                    {<AdStatus />}
                    {<DataShow />}
                    <SelectField label="Status" source="status" choices={[
                        {status: 0, name: "elfogadasra var" },
                        {status: 1, name: "aktiv" },
                        {status: 2, name: "inaktiv" },
                        {status: 3, name: "archiv" },
                    ]} optionText="name" optionValue="status" />
                    <SelectField source="click_type" choices={[
                        { id: 0, name: "CT Hirdetes"},
                        { id: 1, name: "Lead Hirdetes"},
                    ]} optionText="name" optionValue="id" />
                    <DateField label="Letrehozas datuma" source="time" />
                </Tab>
                <Tab label="Jellemzok">
                    <ReferenceField label="Tipus" source="type" reference="categories" >
                        <TextField source="name" />
                    </ReferenceField>
                    <ArrayField source="categories">
                        <SingleFieldList>
                            <ChipField source="name" />
                        </SingleFieldList>
                    </ArrayField>
                    <TextField label="data1" source="data_1" />
                    <TextField label="Kiegeszito adat" source="data_2" />
                    <TextField label="data2" source="data_3" />
                    <TextField label="Kiegeszito adat" source="data_4" />
                    <TextField label="data3" source="data_5" />
                    <TextField label="Kiegeszito adat" source="data_6" />
                    <TextField source="spec_1" label="Termek Jellemzok 1" />
                    <TextField source="spec_2" label="Termek Jellemzok 2" />
                    <TextField source="spec_3" label="Termek Jellemzok 3" />
                    <TextField source="spec_4" label="Termek Jellemzok 4" />
                    <TextField source="spec_5" label="Termek Jellemzok 5" />
                </Tab>
                <Tab label="Jogi es Igenylesi Feltetelek">
                    <RichTextField source="description" label="Jogi Feltetelek" />
                    <RichTextField source="conditions" label="Igenylesi Feltetelek" />
                    <TextField label="Kiemelt kep (URL)" source="image" />
                </Tab>
                <Tab label="Promocio">
                    <DateField source="start_time" label="Idozitett indulas" />
                    <DateField source="end_time" label="Idozitett leallitas" />
                </Tab>
                <Tab label="SiteAds">
                    <ArrayField source="siteads" addLabel={false} >
                        <Datagrid>
                            <ReferenceField label="Hirdeto Oldal" source="site_id" reference="sites">
                                <TextField source="name" />
                            </ReferenceField>
                            <UrlField label="Hivatkozas" source="href" />
                            <UrlField label="Visszahivas URL" source="href_call" />
                        </Datagrid>
                    </ArrayField>
                </Tab>
            </TabbedShowLayout>
    </Show>
);

我的const怎么办?

我在devTools控制台上没有任何错误。

reactjs react-admin
1个回答
0
投票

在他们的同时我发现了这个问题:

在返回时,TextField不知道记录,所以我不得不明确告诉它记录= {record}

<TextField record={record} source="data_1" label={label1} />
© www.soinside.com 2019 - 2024. All rights reserved.