const DataTableEditDemo = () => {
const [columnList, setColumnList] = useState(["code"]);
return (
<div>
<MultiSelect
value={columnList}
options={columns}
optionValue="field"
optionLabel="header"
onChange={(e) => setColumnList(e.value)}
/>
<DataTable value={data} responsiveLayout="scroll">
{columnList.map((val) => {
return <Column key={val} field={val} header={val} filter />;
})}
</DataTable>
</div>
);
};
我想知道这是UI库错误还是我错过了一些东西。对于我的观察,Usestate应该启用此组件,但我猜过滤状态不会更新。
please add key inside setFilters
const [filters, setFilters] = useState({
global: { value: null, matchMode: FilterMatchMode.CONTAINS },
name: { value: null, matchMode: FilterMatchMode.STARTS_WITH },
'country.name': { value: null, matchMode: FilterMatchMode.STARTS_WITH },
representative: { value: null, matchMode: FilterMatchMode.IN },
status: { value: null, matchMode: FilterMatchMode.EQUALS },
verified: { value: null, matchMode: FilterMatchMode.EQUALS }
});