cancel
Showing results for 
Search instead for 
Did you mean: 

sort a context node that has subnodes

daniel_humberg
Contributor
0 Kudos

I have a context node with cardinatliy 0:1.

It has one subnode, 3 attributes, and a recursive node.

Now, I would like to sort the content of the node by one the three attributes.

How can I do that?

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

Hi Daniel,

if I understand you correctly, here's the node structure:


NODE A     0...1
|-----SUB_NODE B
|-----RECURSIVE_NODE
|-----ATTRIBUTE  1
|-----ATTRIBUTE  2
|-----ATTRIBUTE  3

if this is the case, your super NODE A will only have at most 1 element.

with 1 element, why do you want to sort it. I have no idea.

Regards,

Aaron

daniel_humberg
Contributor
0 Kudos

Sorry, i was not precice enough. I would like to sort the second level.

So, I want to sort the nodes of the recursive node, that are directly underneath the root node.

ChrisPaine
Active Contributor
0 Kudos

Hi Daniel,

but if the subnode is mapped on the parent, it will have the same 0...1 cardinality - and it won't make sense to sort it.

If perhaps both the parent and subnode have 0...n cardinality but you are only creating one root element - this makes more sense.

Sorting the second/third/nnn level of a hierarchy is difficult - because it is difficult for the user to specify which level they want to sort. I would assume that you'd just make it so that ALL levels were sorted according to whichever criteria you choose.

You could consider representing your data as a table popin's (which would then make it more obvious which level was being sorted) but if your data has n levels of hierarchy this will very quickly become a nightmare of recursive dynamic coding.

As you are no doubt aware, the standard table sorting logic as implemented in CL_WDR_TABLE_METHOD_HNDL does not work for hierarchical tables. (7.01, goodness knows, it might in 7.02)

So I see two options:

I think you would either have to go down the path of creating your own table handler, unfortunately the standard table handler CL_WDR_TABLE_METHOD_HNDL is marked as final - so you couldn't just subclass that and override the sort handling (which doesn't work for hierarchical tables). Instead you'd probably have to re-implement. Then reassign the handler in the WDDOMODIFYVIEW. I remember doing similar sorts of things to implement sorting in WDJ in the early days when the standard handler didn't do all I needed it to do. (i.e. it was sorting by key rather than by text for dropdown by keys).

Or, in the event when you open/display a node, sort the contents according to the state of toggle buttons that you implement in the root node of your hierarchy. When these toggle buttons change state - recursively sort your your entire context.

This means you don't have to mess with the standard table handler, but does give a very non-standard sort implementation.

Good luck, if you have any questions, please do let us know.

Chris

Answers (0)