在线观看不卡亚洲电影_亚洲妓女99综合网_91青青青亚洲娱乐在线观看_日韩无码高清综合久久

鍍金池/ 問答/HTML/ antd 在class外部的modal如何獲取Table列表的值?

antd 在class外部的modal如何獲取Table列表的值?

class 內(nèi)
 columns = [
        {
            title: '用戶賬號(hào)',
             dataIndex: 'uiAccount',
             key: 'uiAccount',
        },
        {
            title: '用戶姓名',
            dataIndex: 'uiName',
            key: 'uiName',
        },
        {
            title: '郵箱',
            dataIndex: 'uiEmail',
            key: 'uiEmail',

        },
        {
            title: '用戶備注',
            dataIndex: 'uiRemarks',
            key: 'uiRemarks',

        },
        {
            title: '角色',
            dataIndex: 'roles',
            key: 'roles',
            render: (text, record, index) => (
                <Fragment>
                    <Button type="primary" onClick={() => this.showModal(true, record)}>查看/設(shè)置</Button>

                </Fragment>
            ),
        },

        {
            title: '操作',
            dataIndex: 'caozuo',
            key: 'caozuo',
            render: (text, record, index) => (
                <Fragment>
                    <Button onClick={() => this.editUser(record)} type="primary">修改</Button>
                    <Divider type="vertical" />
                    <Button type="primary" onClick={() => this.delUser(record)}>刪除</Button>
                </Fragment>
            ),
        },
    ];
    render(){
     <Table                     
                dataSource={list}
                columns={this.columns}
                onChange={this.handleStandardTableChange}
                rowKey={(record) => record.uiAccount}
           />
    }

點(diǎn)擊修改后會(huì)有一個(gè)modal顯示(代碼在class外部) 需要顯示點(diǎn)擊行的值,
如果在點(diǎn)擊之前 使用 form.setFieldsValue 會(huì)如下錯(cuò)誤
clipboard.png
未顯示的組件不會(huì)被form.getFieldDecorator注冊(cè)
可以參考這個(gè)issue https://github.com/ant-design...
如果不想點(diǎn)修改之后從服務(wù)器獲取數(shù)據(jù),而是從Table里存儲(chǔ)的數(shù)據(jù)獲取,應(yīng)該怎么寫?

回答
編輯回答
近義詞

把這個(gè)modal的掛載點(diǎn)設(shè)置到class內(nèi),就可以獲取到了。

<Modal getContainer={document.getElementById('your mount dom')}/>
2017年7月12日 17:30
編輯回答
柒喵

自己寫了方法實(shí)現(xiàn)了
在點(diǎn)擊按鈕的時(shí)候?qū)⑿袛?shù)據(jù)傳入props,再用mapPropsToFields在filed初始化之后寫入數(shù)據(jù),比較繞,但是不用走服務(wù)器,可以節(jié)省流量

因?yàn)?mapPropsToFields 是在 Field 被初始化的時(shí)候調(diào)用的。而 setFieldsValue 調(diào)用時(shí),F(xiàn)ield 還未被初始化。
2018年1月30日 18:40