[GTree] Ordering Nodes?
Question
Application Type
Reactive
Service Studio Version
11.14.12 (Build 59645)

Hello all,

Would anyone know how to ensure ordering of the nodes in each level of a GTree component, alphabetically by the NodeName property?

At first I assumed that GTree might order the nodes of each level by NodeName automatically, so I left the component's source aggregate unsorted.  Unless I've missed something, it doesn't appear to do this automatically so I tried applying a couple of different sort variations on the source aggregate and that doesn't appear to work either.

From what I can tell, it appears that GTree is ordering the nodes of each level by the Id of the node.  If correct, is there a way to override this so that the nodes of each level display in order by NodeName?

Thanks all, and great job Pedro Neto on the Gtree component!

John

Champion
Solution

Hi John, Right now I don't have the time to delve into the details, but I don't want to leave you with an unanswered question.

I can't remember for sure if it is sorting by the id, but I think you are right. Would it be an acceptable solution to add a calculated field to your aggregate that reflects that desired order and then use that as the Id attribute that you pass on to the GTree component ?


Best regards and thank you for your review.

Pedro Neto

Thanks so much for getting back to me Pedro!

I think that might be a really good solution.  I am currently using NodeId to hold the Id of the aggregate, but I can precede it with what I'm using for the NodeName in a way that allows me to regex the Id back out, e.g. "Sales Division::1::", "Accounting Division::3::".  This should get me my sort, while not losing access to the Id.  Should work just fine.

I'll give that a shot and let you know how it goes.

Thanks!

John

Hi Pedro,

I got it working using your suggestion. :-)

I added the two calculated columns to my aggregate - one for node Id "name::id::" and one for parent Id "parent_name::parent_id::" and used those for GTree's NodeId & ParentNodeId.

At first the tree still displayed as before - seeming like it was still displaying in either the aggregate's Id or row creation order.  So I went back in and added a sort on name and viola - it works.

So it seems as though if NodeId & ParentNodeId are set to my aggregate's Id columns, the tree displays in Id order whether my aggregate is sorting by name or not.  But if NodeId & ParentNodeId are set to something else like the concatenation I have above, then as long as the aggregate is sorted by name then the tree will display by name.  Curious, but it's working so all good!

Thanks again for the help!

John

Community GuidelinesBe kind and respectful, give credit to the original source of content, and search for duplicates before posting.