material-table中是否有自定义排序功能来对文件大小进行排序?

Is there a custom sorting function in material-table to sort file sizes?

我正在使用 material-table (mbrn/material-table) 开发仪表板,我的列中包含的内存值分别为兆字节 (MB) 和千兆字节 (GB)。 由于文件大小不同,正常排序选项无法按预期工作。 material-table 中是否有自定义排序功能来对文件大小(MB 和 GB)进行排序?

https://github.com/mbrn/material-table.git

以上 github 回购我用来开发仪表板。

不,但您可以在几秒钟内编写自定义逻辑来创建您自己的过滤器。

// your logic
const sortBySize() = (row, value) => {
     console.log('row', row, 'value', value);
} 

const columns = [
    { title: "File name", field: "fileName" },
    { title: "size", field: "size", customSort: sortBySize() }
];

有用link:https://material-table.com/#/docs/features/sorting(自定义排序算法示例)