鍍金池/ 問(wèn)答/HTML/ antd Table組件 某一列自定義渲染后進(jìn)行排序。

antd Table組件 某一列自定義渲染后進(jìn)行排序。

Table表格中名稱(chēng)這一列自定義渲染內(nèi)容,sorter設(shè)為true可排序,dataIndex為空;
點(diǎn)擊排序后這一列無(wú)法進(jìn)行排序 ,參數(shù)都沒(méi)有 。
dataIndex:‘name’后又會(huì)報(bào)錯(cuò)
{
title: '名稱(chēng)’,
dataIndex: '',
sorter: true,
render: (text) => {
const name = text.name ==null ? <span>已刪除</span> : text.name;
return name;
}

回答
編輯回答
悶騷型

請(qǐng)仔細(xì)閱讀文檔
clipboard.png
如果不是服務(wù)端排序還是前端自己寫(xiě)函數(shù)排序吧

sorter: (a, b) => a- b,//自己寫(xiě)排序規(guī)則

dataIndex必須設(shè)置,并且唯一

2017年12月30日 04:33