[GTree] Sorting Issues
gtree
Forge component by Pedro Neto
Application Type
Reactive

Hi Pedro, how are you?

I am having an issue related with sorting the data displayed on the Tree. The NodeList that i build is sorted precisely the way i want to but, somehow, the output always changes the order making it randomly ordered instead of alphabetically ordered.

Is there a way to overcome this?

Cheers,

Pedro Domingues

Champion

Hi Pedro, all good and you ? 

The component is using the NodeId to sort, what are you putting on that field?

Can you provide an example of a list that is not ordered?


Best regards,

Pedro Neto

The description says that the tree is going to be ordered using the order of the list itself.

Why are you overridding the order of the list that is sent to the component?

I am alphabetically ording the Tree list by it's name. The Node ID is the ID of the Record not the name which i want to sort.

I don't have an example right now but i think the use case is easy to understand.

Champion

The use case is pretty simple yeah, but you might have found a bug related to the way the tree is mapped from list to tree and vice versa, or anything else. 

I don't have much free time right now, so if you can provide an example so that I can dig deeper what's happening and improve the component.

If you happen to find a solution in the meantime also please free to contribute.


Best Regards,

Pedro Neto



Hi Pedro,

Here's an example:

The list that is being sent to the component:

The list that is displayed on the Tree:

As you can see, the highlighted zone should be displayed as the first sub category and its content should be alphabetically ordered as well.

Cheers,

Pedro Domingues

Champion

Thank you, 

I investigated this a bit more, and I can share with you that the tree you are passing is a list, but internally as a javascript object a tree is maintained in memory, meaning there are some calculations done to create the tree from the list. The first step is to create an hashtable with all the nodeIds as keys, meaning that when I iterate them to build the tree they will be ordered by NodeId.

For the time being I suggest you change the NodeIds to something ordered. You can also use the name of the nodes as ids if they are unique.


Best regards,

Pedro Neto


That's what i was thinking! Using the names as the NodeId's for the time being!

Please let me know once you have found a "solution" for this!

Many thanks for you cooperation.

Cheers,

Pedro Domingues

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