on 02-17-2014 1:27 PM
Hey,
I plan to use the model path of the currently selected TreeNode of a Tree in various parts of my application. I could not find a bindable "selectedNode" property for trees, so I planned to set an "activeElement" property in my root model. I wanted to do this by setting the respective property in the selection handler of the tree.
My initial model data looks somethign like
{
activeElement: undefined
}
When invoked, my handler
function(oControlEvent) {
var path = oControlEvent.getParameters().nodeContext.getPath()
var model = sap.ui.getCore().getModel();
var elem = model.getProperty(path);
model.setProperty("/activeGameElement", elem.isGameElement ? path : undefined);
}
throws the following error
Uncaught TypeError: Cannot call method 'placeFocus' of undefined TreeNode.js:14
sap.ui.commons.TreeNode.onclick TreeNode.js:14
sap.ui.core.Element._callEventHandles sap-ui-core.js:117
sap.ui.core.Element._handleEvent sap-ui-core.js:117
sap.ui.core.UIArea._handleEvent
Any ideas how to do this would help me alot.
The problem is that my tree nodes are bound to the same model. So updating the model recreates all nodes and TreeNode's onClick handler can not invoke 'placeFocus' anymore (as the node is gone).
I solved this by using a second model for the activeGameElement property. The confusion of domain and app data bugged me anyways.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
80 | |
24 | |
11 | |
9 | |
7 | |
6 | |
5 | |
5 | |
4 | |
4 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.