Incorrect sorting result if mixing with Chinese and English characters together.
Normally, the ones with Chinese-char should be after the English ones.
I have worked out why this issue happened: the sorting depends on the language option of the web explorer using.
When it is in Chinese, the Chinese chars will rank in the first place; on the contrary, if in English, the sorting results as normal.
Is there any solution for this issue? e.g. ignore the UI language option of the web explorer…
|
@Component({
selector: 'app-root',
template: `<ejs-grid [dataSource]='data' [allowSorting]='true' height='315px'>
<e-columns>
<e-column field='CustomerID' [sortComparer]='sortComparer' headerText='Customer ID' width=150></e-column>
. . .
</e-columns>
</ejs-grid>`
})
export class AppComponent implements OnInit {
// The custom function, you can add your custom logic here
public sortComparer = (reference: string, comparer: string) => {
if (reference < comparer) {
return -1;
}
if (reference > comparer) {
return 1;
}
return 0;
}
}
|