I am having a problem getting data from a branchResultSet
after using the applySort
on the view. The reason I am using that is because I want a limit of 10 records back and not the whole thing for better performance. When I use only the data method it works as expected.
Example code:
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();
//...
I expected to see collection sorted.
If I use this.studentView.data()
, I see the data sorted as expected.
When I use applyWhere
it works as expected.
Using the branchResultSet
method also didn't work with applySimpleSort(param)
.
applyFind
also works as expected.
My only issues have been with both Sort methods.
I'm using StencilJS and TypeScript but I don't believe the issue is with those frameworks because I tried running similar code on a Vanilla HTML-JavaScript and had the same problem.