如何忽略角度材料表中的空值排序

如何忽略角度材料表中的空值排序

本文介绍了如何忽略角度材料表中的空值排序的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在向表中添加一行,以便添加一条新记录,并且无论排序标题是什么(asc、desc 或无),我都希望将该行保留在顶部.

I am adding a row into table, in order to add a new record and i want to keep that row at top regardless the sort header (asc, desc or none).

当没有定义 order 或 asc 时,该行在顶部,但当单击 desc order 时,该行转到底部.

When no order or asc is defined the row is at top but when desc order is clicked the row goes to bottom.

关于如何将空值(数据源中的新行对象具有用于列排序的空值)始终保持在顶部的任何想法?

Any ideas on how to keep null values (new row object in data source has null values for column sort) always at top?

无订单即可:https://i.stack.imgur.com/J3Ou1.png

Order Asc 也可以:https://i.stack.imgur.com/xFolC.png

Order Asc is OK too:https://i.stack.imgur.com/xFolC.png

但是订单描述不行:https://i.stack.imgur.com/bsksj.png

推荐答案

当值为 null 时,可以用Z 之后排序的字符替换"它,例如 omega (Ω),通过覆盖排序机制.

When the value is null, you can 'replace' it by a character that sorts after Z, for example omega (Ω), by overwriting the sorting mechanism.

this.dataSource.sortingDataAccessor = (item, key) => item[key] || 'Ω';

排序机制会返回键/值对,但是当没有找到值时,它会返回omega字符,但是只用于排序,所以它不会出现在你的表中.

The sorting mechanism will return the key/value pair, but when no value is found, it will return the omega character, but for sorting only, so it won't show up in your table.

这篇关于如何忽略角度材料表中的空值排序的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-24 19:29