react-antd-admin-panel
Version:
Easy prototyping admin panel using React and Antd
30 lines • 1.24 kB
JavaScript
const handleDefaultProps = (col, { data }) => {
var _a, _b, _c, _d;
col.editable = (_a = col.editable) !== null && _a !== void 0 ? _a : false;
col.sortable = (_b = col.sortable) !== null && _b !== void 0 ? _b : false;
col.searchable = (_c = col.searchable) !== null && _c !== void 0 ? _c : false;
col.filterable = (_d = col.filterable) !== null && _d !== void 0 ? _d : false;
if (col.sortable) {
col.sorter = (a, b) => {
if (a[col.dataIndex] < b[col.dataIndex])
return -1;
if (a[col.dataIndex] > b[col.dataIndex])
return 1;
return 0;
};
}
if (col.filterable) {
col.searchable = false;
if (col.useFilters) {
col.filters = [...col.useFilters];
}
else {
col.filters = data.map((r) => r[col.dataIndex]).filter((item, i, self) => item && self.indexOf(item) === i);
}
col.filters = col.filters.map((r) => { return { value: r, text: r }; });
col.onFilter = (value, record) => record[col.dataIndex].indexOf(value) !== -1;
}
return col;
};
export default handleDefaultProps;
//# sourceMappingURL=ListDefault.js.map