1. 程式人生 > >react table filters篩選用法

react table filters篩選用法

1.
filters的資料是陣列,把獲取相應的陣列使用map方法,將資料轉換為text:,value:,
再將onFilter:(value,record) => { 
    return record.  = value
}
例子:

store:

let type = [];
            for (var key in x.data.category) {
                if (x.data.category.hasOwnProperty(key)) {
                    type.push({
                        name: x
.data.category[key].name, id: key }) } } this.skuType = type.map(x => ({ text:x.name, value:x.id }));
{
            title: '分類',
            dataIndex: 'catename',
            key: '分類',
            filters: toJS(this
.props.sku.skuType) || [], onFilter: (value, record) => { return record.cateid === value}, }