reactjs - React.js material-ui:用逗号屏蔽时是否可以对数量进行排序?
问题描述
我有一个包含一Total Amount
列的材料表
在我添加逗号屏蔽之前,此列上的排序有效,因为有例如 1,000.00
material-table
是否可以修改内置的升序/降序排序以使用屏蔽量?
谢谢
请参阅编辑。
TIA
解决方案
是否可以修改材料表的升序/降序的内置排序以使用屏蔽量?
是的,有可能。您需要使用自定义排序。使用customSort
列数组中的方法来传递为您排序的函数。
<MaterialTable
title="Custom Filtering Algorithm Preview"
columns={[
{
title: 'Name',
field: 'name',
customSort: (a, b) => a.name.length - b.name.length
},
{ title: 'Surname', field: 'surname' },
{ title: 'Birth Year', field: 'birthYear', type: 'numeric' },
更多信息在这里https://material-table.com/#/docs/features/sorting
在你的情况下
{
title: "Total Amount",
field: "totalAmount",
filtering: false,
customSort: (a, b) => { ... write your sort logic here}
},
推荐阅读
- ios - 无法将领域数据从 tableViewController 传递到 viewController
- django - /student/test/ 的 NoReverseMatch 为“single_quiz”反向,未找到参数“(”,)”。尝试了 1 种模式:['quiz/(?P
[0-9]+)/$'] - angular - ngx-datepicker 标头为空
- angular - Http Post返回两组数组,如何将这些数组存储在两个不同的角度观察中
- apache-kafka - Apache Kafka 补丁发布升级流程
- angular - 如何使用 *ngFor 外部的索引访问数据
- firebase - 离子推送连接到 API (Firebase)
- mysql - 为评估为真的 IN 条件元素设置限制
- python - Python:如何分隔字符串中的字符和数字
- node.js - Dockerizing ReactJS 项目得到:“命令 sh -c react-scripts start”错误