Sorting

Hi,

I am testing with sorting.

I use a parent form with a related tab on it showing the child records.

Is it possible to set a sortorder on the tab (child) form that is “sticky” ?

By that i mean that the sort order in the tab form stays the same when navigating through the parent records.

The behaviour as I see now is that the first set of child records are sorted correct, but if i navigate to the next parent record
(which also shows a new set of child records) the child records belonging to this parent are not sorted.
I tryed setting controller.sort , foundset.sort and relation.sort on the child form, but they all only seem to work on the
first set of child records.

any ideas ?

Regards,

In the documentation it says ( for controller.sort and relation.sort ) :

NOTE: The sort order you specify in the sort function will continue apply to the specified form - independent of the foundset - until you modify the sort order.

But that does not work.
As soon as i navigate to the next parent record the new set of records in the child form are not sorted !

Or do i miss something ?

That documentation isnt correct
The sort that you set is stable and reused for that foundset so if you do a load all or a find in that foundset that sort is reused.
for relation.sort() you really call it on that foundset, for controller.sort() you call it on the current foundset in that form.

Also if you would display a related tabpanel it would try to use that current sort as a default sort of the related foundset but if the foundset is already loaded it will not resort it.

In 4.x you can now default sort the related foundset by the sort property in the relation editor.

Servoy 4.1 hitting Sybase SQL Anywhere 10 on Mac OSX

I have forms where I preload all records on application startup and sort them. The code looks like this:

 controller.sort('sort_column asc')
foundset.getRecord(databaseManager.getFoundSetCount(foundset))

When a user adds a record, I want to sort the foundset so the new record will appear in the right sort order, so I do the following right after the record is saved:

	var vPK = record_pk
	controller.sort('sort_column asc')
	foundset.selectRecord(vPK)

This works fine in most cases: all the pre-loaded records remain in the foundset, and the newly created record becomes sorted and selected.

But I’ve found one situation where it’s failing. If sort_column is a text field of length 50, the sort command is causing the foundset to revert back to the first 200 records. Often this means that the newly created record is no longer in the foundset.

Oddly enough, this is only happening when SQL Anywhere is running on Mac OSX. The code works fine when hitting SQL Anywhere running on WinXP.

For now I am working around this by forcing another “pre-load” of all recors each time a new record is added, but obviously I’d prefer not to have to do this.

Does anyone know what’s causing this? Is it a Sybase/Mac thing? Is it the result of sorting on a column that’s 50 char long? Is this Is there a better way of doing this?

Thank you.

if you sort, it will always fall back to 200 records.

and this:

       var vPK = record_pk
       controller.sort('sort_column asc')
       foundset.selectRecord(vPK)

will not select your current pk if the pk falls out of the 200 records.
so if you really want that then you first have to load the numbers of records you want
(while(size != getMaxRecordIndex()) getRecord(getMaxRecordIndex)) (something like that)
and then call select record

I think I know what’s going on.

What I’m finding is that if the table has between 200 and 400 records when I issue the sort command, and if the sort key is the same as the current sort, then it doesn’t fall back to 200 records. But if the there are 400+ records in the table then it does fall back to 200 regardless of the sort key used.

So it has nothing to do with whath OS, what db or what type of sort column I am using, it all has to do with the number of records in the table.

Thanks for your help.

as far as i see what ever you put in the sort (the same or something else as the previous sort) a new query is done
and if you do a new query only max 200 pks are get so when you then select then a pk that fall out of that it will not select it.