PavelGudkov
Enthusiast
Enthusiast

vRA 8: Sorting of properties for dynamic list in custom form

Hi all,

I want to provide for users list of sorting values in Custom Form using vRO Action (for example: tier-1, tier-2), but sort order in Properties object is not alphabetic. Is there some way to sort elements in Properties object?

Examples:

step1.JPG

But

step2.JPG

0 Kudos
2 Replies
rwk1982
Enthusiast
Enthusiast

Hello!

Properties are not sortable in JavaScript. I use this workaround (only tested in vRA 7.x):

var sortme = ["t1@tier-1","t5@tier-5","t3@tier-3","t2@tier-2","t4@tier-4"]

var val2return = []

for each (item in sortme.sort()) {

     var prop = new Properties();

     prop.put('label',item.split("@")[0])

     prop.put('value',item.split("@")[1])

     val2return.push(prop)

}

return val2return

Drink coffee.. Do stupid things faster with more energy...
craigso
Enthusiast
Enthusiast

Yep, I did the same as Robert. Create an array of properties, add the properties into the array in a sorted way, and they will be returned in the way you'd expect.

0 Kudos