我branchResultSet
在使用applySort
视图后从 a 获取数据时遇到问题。我使用它的原因是因为我希望返回 10 条记录的限制,而不是为了获得更好的性能。当我只使用数据方法时,它按预期工作。
示例代码:
switch() {
// ...
case 'Name':
// This code was added elsewhere. I added this as an example of how I
// initialize the variable studentView.
this.studentView = studentColl.addDynamicView('view');
/////////////////////////////////////////////////////
this.studentsView.applySort((a: IStudent, b: IStudent) => {
if (a.firstName.toLowerCase() < b.firstName.toLowerCase()) {
return -1;
}
if (a.firstName.toLowerCase() > b.firstName.toLowerCase()) {
return 1;
}
return 0;
}).applySort((a, b) => {
if (a.lastName.toLowerCase() < b.lastName.toLowerCase()) {
return -1;
}
if (a.lastName.toLowerCase() > b.lastName.toLowerCase()) {
return 1;
}
return 0;
});
break;
};
this.students = this.studentsView.branchResultset(lokiViews.viewPaging, { pageStart: 0, pageSize: 10 }).data();
//...
我希望看到集合排序。
如果我使用this.studentView.data()
,我会看到按预期排序的数据。
当我使用applyWhere
它时,它按预期工作。
使用该branchResultSet
方法也不适用于applySimpleSort(param)
.
applyFind
也可以按预期工作。
我唯一的问题是两种排序方法。
我正在使用 StencilJS 和 TypeScript,但我不认为问题出在这些框架上,因为我尝试在 Vanilla HTML-JavaScript 上运行类似的代码并且遇到了同样的问题。