1

I have a complex client / server system to manage master data in the industry. Much of this data is represented by a deep tree structure.

What is the best thing to do at this point?

  • Always show the expand button for each node?
  • Calculate in the server if the respective node has child elements and set for this a property which the client can evaluate to display the expand button?

For the latter I would then always have to query the table with the children, if there is at least one, which has the node as parent element and for each node.

The more nodes I query, the longer the query takes so synonymous. Ok, I have paging with it, but even then it is so that I have to make 101 queries for 100 elements.

I do not want the button is always displayed, but if the response time is too big, I will have no other possibility, right?

1
  • 2
    I don't really understand the issue here. If you have a tree structure where some nodes can be expanded to view the children, but some can't be expanded because they don't have children, the correct way to deal with this is to show an expand button only for the ones that can be expanded. Are you asking for technical advice on how to achieve that?
    – JonW
    Commented Aug 31, 2017 at 10:00

2 Answers 2

0

No, don't show the button if there are no nodes. That's like a business card saying "phone number: I don't have one". It's useless.

And the performance issue isn't actually there. It is if you straight up search every time, yes. But you shouldn't. You should store a boolean somewhere for all the nodes. Mysql table, xml file, excel sheet, don't care. Then just run 1 query to retrieve ID, NAME, HAS_NODE, ETC, for your initial 100 nodes. Then show them, and throw an 'expand' button on some. When clicked, retrieve the child nodes (should be a single query) and retrieve ID NAME HASNODE for those.

That's 1 query to start, and 2 more per expansion. Not 100 initial queries most of which never end up getting expanded.

2
  • A boolean is not the really a good solution. Every time I change a child, I must update the parent. But ok, I have my answer. Don't show the expand button. Thx
    – user106267
    Commented Sep 1, 2017 at 4:11
  • @Frank Not every time you change anything. Only when you add or remove a child. What I'm saying is you should separate your hierarchical data from the individual data per object. Commented Sep 1, 2017 at 7:18
0

Don't show the expand button when there's nothing to expand. It is very annoying when you do not know which items have children and having to click them to find out. Also it's annoying to wait, not knowing how long and see nothing happen when there are no children.

With my technical experience it doesn't sound very logical that you need more than one query for this. It has been done before. Since this is not the right site for it, ask for technical advice on Stackoverflow.

2
  • StackOverflow isn't there to write code for people from scratch. If there's no code in a question then it'll just get closed straight off.
    – JonW
    Commented Aug 31, 2017 at 16:24
  • @JonW Sorry, it wasn't my intention to make it sound that way. Edited!
    – jazZRo
    Commented Aug 31, 2017 at 17:16

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.