initialSort not executed under certain circumstancs

Hi All

I would like to ask if others have found that under some circumstances the initialSort does not execute. I have a form where I’d like to sort a field, displayed in the form, with the initialSort property. The form has a parent form (relationless), and this parent form is loaded with the method elements..addTab().

Under this circumstance, the initialSort is not executed.

BTW, when exactly is initial, i. e. when is initialSort triggered? Are there dependencies if it’s a module, or loaded with addTab() etc.?

Best regards, Robert

Servoy Developer Version: 4.1.4 - build 681
Mac OS X 10.5.8
java version “1.5.0_20”

Hi Robert,

Is this form the only one with this (shared) foundset ? When there is another form with the same foundset that might be loaded first then your initialSort on the second form won’t trigger (is my experience).

if a foundset is already sorted before, initalSort does not work.
we found out that the best way to use this, is on non related data:

in onLoad of form:

foundset.clear()//preventing from loading the data already

in onShow of form:

if(arguments[0]) { //only do this the first time onShow is fired
if(foundset.find()) {
mycolumn = 'mysearch'
foundset.sort(column, asc)
foundset.search()
}
}

I’m doing this out of my head ;-) so there can be typos…

Or with related data, set the sort IN the relation.

Hi Harjo

Thanks. The reason why I don’t want to do the sorting in the onShow() method, is because if the user sorts (manually) a column (the form is in table view), changes to another menu and comes back to this menu, his previously set sort is overridden, as the onShow is triggered again. Yes, I could use isFirstTime in onShow (arguments[0]) as your code shows, but I mean that’s what initialSort should be for. initialSort is for this purpose elegant, but if it’s dependant on many (unknown) prerequisits, it’s really difficult to use and never will reach any useful consistency (from the users perspective).
BTW, I assume the mention dependencies are nowhere noted, just found out by the various developers? :cry:

Best regards, Robert

Harjo:
if a foundset is already sorted before, initalSort does not work.
we found out that the best way to use this, is on non related data:

in onLoad of form:

foundset.clear()//preventing from loading the data already

in onShow of form:

if(arguments[0]) { //only do this the first time onShow is fired

if(foundset.find()) {
mycolumn = ‘mysearch’
foundset.sort(column, asc)
foundset.search()
}
}




I'm doing this out of my head <img src="{SMILIES_PATH}/icon_wink.gif" alt=";-)" title="Wink" /> so there can be typos....

Or with related data, set the sort IN the relation.

Maybe you can do something in first call to onShow() and test what the current sort is.
If it is just default then do you sort.