Hello,
I ran into a sorting bug in my solution, and was able to reproduce it in the CRM demo:
- Switch manually to the “list_contacts” layout
- Select the first record in the list
- Perform any kind of sort (like last name desc, first name desc)
The original record is no longer selected. In fact, the first record is selected again. If you initially select any other record, that record remains selected after a sort, as expected.
Can anyone reproduce this?
Also, is it normal behavior for the onRecordSelection event to trigger during a sort?
Your question can only apply to tables with few rows. Imagine you are looking at 20.000 records sorted from A-Z and select the third record. Now you reverse that sort. How can the original record be selected? Servoy would have to load all 20.000 and jump to the third last record. I don’t think anyone would like that…
Hi Patrick,
If sorting performance is an issue with large datasets, then couldn’t you simply alert the user, like “Hey, this might take a while”, and give the option to cancel the sort?
Also, I still don’t understand the behavior as described in my initial post (why the record loses its selection when it’s the first). Imagine a list of patients on the left side of a form, and the details of the selected patient on the right (including a picture). It’s very disconcerting from a UI standpoint to see a different photo when sorting by date of birth.
Hi Sean,
Sorting is not the problem (it’s all done by the RDBMS, not Servoy). In Patrick’s example the issue is that Servoy need to load 20.000 records and then scroll to the last 3rd record since that was the original selected record.
Loading 20.000 records will be very costly.
Hi Robert,
Loading 20.000 records will be very costly.
Understood, but Servoy isn’t even being consistent with a foundset of four records, which is what I was working with when I noticed the apparent problem. Right now, Servoy is selecting the original record after a sort, except when the original record is the first. I’m just trying to understand why.
FWIW, since I program all my sorting manually, I wonder if I can work around this issue by recording the primary key before sorting, and then doing a selectRecord(pk) after sorting.
I think you did hit some inconsistent behaviour here. My impression is that in a table view sometimes no record is really selected (instead of the first). So in your case it could be that you think that the first record is selected but for Servoy it is not really selected. What happens if you really click on that first record before your sort?
Hi Patrick,
That’s a good thought, but I still see the same inconsistent behavior in the CRM demo. Also, in my solution I see the problem in list view as well. If you have the demo files installed, can you reproduce the problem as described in my initial post?