Happy new year!
Am I correct to say that there is no real easy way (i.e. standard functionality) to have all the nodes expanded if the 'treeTable' is in a 'filter-state'?
What I mean is that if the filter searchbox is not empty all the matching nodes are expanded, but otherwise the nodes are in a default (collapsed or some other dynamic expansion) state.
Apart from that I want to have my tree expanded to the point of a selected node, if this is loaded from a backing bean. So I have a
<q:singleNodeSelection nodeData="#{activityAgentTree.activityNode}" />
And it's loaded alright, but it's not expanded up until that level. Maybe someone can give me a few pointers on how to procede with that?
Hello Auke,
Yes, you are right, there is no way to expand nodes when the filter is applied. We will consider adding this feature in one of the future releases of QuipuKit.
Regarding your second question. Unfortunately, I don't fully understand your use case. Are you trying to change selection from the backing bean and then expand the TreeTable up to the selected node?
Regards,
Tatyana
Regarding your second question. Unfortunately, I don't fully understand your use case. Are you trying to change selection from the backing bean and then expand the TreeTable up to the selected node?
Well, not 'change' as in that I need to check for changes every once in a while, but more like if I have a saved state from an earlier usage of the treetable (i.e. I selected a node). If I then 'editi' this selection I was thinking that
<q:singleNodeSelection nodeData="#{activityAgentTree.activityNode}" /> would at least expand the treetable up unto the point of selection and selecting that node. It could also be that my getActivityNode() isn't properly implemented. I have a generic Tree implementation that wraps the data of the node. Upon selecting a node I only save this data of course, so when I want to edit this data I have to do something along the lines of:
Activity activity = someManager.getActivity();
return new JobActivityNode<Activity>(activity);
I was assuming that because hashCode() and equals() are correctly implemented the tree would now which node to select + expand. But maybe this is not the case.
PS: is is just me or do I miss a way to 'code-format' my code? Not to mention the rest of the messy formatting.
Hello,
It's still not clear. However, I'll try to explain as I understand it now. You have a TreeTable with a single selection enabled. The user can change the selection on the client-side. And also you need to save the selection, so when the page with the TreeTable is opened next time, the previously selected node is selected again. You are correctly using the nodeData attribute to save the selection.
And also the TreeTable has some default expansion state. As I understand, all nodes are collapsed. You want the TreeTable to be expanded up to the selected node when the page is opened. If you specify the expansionState attribute as binding, the expansion state will be saved.
And regarding your question about the code formating. At the present, there is no possibility to format a code snippets when you use the "Rich Text" editor. However, if you switch to the "Plain Text" editor, you can use the WIKI markup, including code formating (use the some code markup).
Regards,
Tatyana
Thank for sticking with me ![]()
You are correctly using the nodeData attribute to save the selection.
Indeed the saving works like a charm, however I was under the impression that binding this to a property would also automagically select the right node again if the binding property had a non-null value. I'm not terribly fluent with JSF yet, but if I use a value along the lines of
<h:inputText value="#{manager.property}" ></h:inputText>for my inputText and this property gives me a non-null value (i.e. I edit the form) it will present me with this value in the form. Therefore I thought that populating the nodeData with a saved value:
public TreeNode getActivityNode() {
return activityNode;
}
would present me with a tree that had the correct selection, and the correct expanded state. However this does not work for me, but maybe this is by design.
And also the TreeTable has some default expansion state. As I understand, all nodes are collapsed. You want the TreeTable to be expanded up to the selected node when the page is opened. If you specify the expansionState attribute as binding, the expansion state will be saved.
If the above doesn't work automatically, it boils down to this: I will have to retrieve the information from the database, look it up in my tree-structure (which only exists on the 'UI' side), and then call setNodeExpanded( ... ) on every parent of that node?
Regarding selecting node in the backing bean on the first page load. From your code, it seems that you bind the nodeData attribute of the singleNodeSelection tag to the property of the TreeNode type. It is not correct, you should bind it to the property of the same type as the value attribute of the DataTable is bound to. If you set the initial value for this property, for example in constructor, it should be selected when the page is loaded first.
Regarding expanding one specific node. You should use the expansionState of the DynamicNodeExpansionState type. For more details please see the http://support.teamdev.com/message/2591 thread.
Any further questions are welcome.
Regards,
Tatyana
Regarding selecting node in the backing bean on the first page load. From your code, it seems that you bind the nodeData attribute of the singleNodeSelection tag to the property of the TreeNode type. It is not correct, you should bind it to the property of the same type as the value attribute of the DataTable is bound to.
The value property of the datatable? Am I really missing something or do you mean that it should be bound to the same type as an element in the list that is given to the nodeChildren attribute of the dynamicTreeStructure element? In that case TreeNode is correct, because those are actually the elements in that list.
I must go on with some other stuff for now, so I'll try to figure some things out before my evaluation ends, but I'll be back in a few days to this thread I guess.
Sorry, yes you are right. I mean that it should be bound to the same type as an element in the list that is given to the nodeChildren attribute of the dynamicTreeStructure element.