PDA

View Full Version : Is there a way to sort a list by multiple controls via script vs. xml tags



irpagan
May 20th, 2015, 23:58
This is going to sound like an odd question, is there a way to sort a list by multiple controls via script vs. xml tags. I know you can do this;



<sort>
<control>skilltype_hdn</control>
<control>name</control>
</sort>


The problem I have is <delaykeyupdate /> will not work in this instance - or maybe I should rephrase that to I am not sure how to make it work correctly in this instance.

What I would like to have happen is the list sort uses the value of skilltype_hdn and name after both are filled. The intent is to create a function and call sort once I'm ready for it to be applied.

In my list I have a cycler control for skill type, since you can't sort on a cycler I created a hidden value called skilltype_hdn. I put <delaykeyupdate /> on name and skilltype_hdn which gets populated by the onValueChanged() event from the cycler. Unfortunately what happens is the list resorts immediately because skilltype_hdn loses focus as soon as it's written to.

If not I'll either have to live with it or figure something else out. I rooted through some code but didn't see anything that stood out although I will feely admit it was a quick search.

Regards,
-d0gb0y

Trenloe
May 21st, 2015, 00:38
In windowlist controls you can use the onSortCompare (https://www.fantasygrounds.com/refdoc/windowlist.xcp#onSortCompare) event handler to programatically change the order.

Do a find in files in the CoreRPG ruleset for onSortCompare and you'll find a few examples.

irpagan
May 21st, 2015, 01:02
Thank you.