PDA

View Full Version : Migrate question from version 3



noamway
20 Dec 2012, 1:51 AM
1)
In verstion 3 I got this option:
Ext.getCmp('treePagesList').getNodeById(nodeID).select();
How can I do that in version 4?

2)
In verstion 3 I got this option:
Ext.getCmp('treePagesList').getNodeById(nodeID).ensureVisible();
How can I do that in version 4?

3)
In verstion 3 I got this option:
Ext.getCmp('treePagesList').getNodeById(nodeID).setText(newText);
How can I do that in version 4?

Thanks,
Noam

tvanzoelen
20 Dec 2012, 2:11 AM
Maybe there are better shorthand rightnow, but below are some options


1



var node = treePanel.store.tree.getNodeById(id)
//var node = tree.getStore().getNodeById(Id);
treePanel.getSelectionModel().select(node);

// or

treePanel.selectPath(node.getPath());



2


var record = tree.getStore().getNodeById(Id);
var viewNode = Ext.fly(tree.getView().getNode(record));

if (viewNode) {

viewNode.setVisibilityMode(Ext.Element.DISPLAY);
viewNode.setVisible(visible);
}


3



node.data.text = 'text';
node.text = 'text';

noamway
20 Dec 2012, 3:22 AM
Thanks for the help,
After I update the text like you wrote the tree not change with the new name, any option to see the change without using the 'load' option?

Thanks

tvanzoelen
20 Dec 2012, 3:28 AM
Whats the displayfield you have set in the treePanel? Default it is text, but you could have altered that,



node.set('text', 'value');

noamway
20 Dec 2012, 4:54 AM
I tried what you wrote but the change doesn't work on the tree (only after I reload the all tree I see the change).

This is what I have now and it's not working:
Ext.getCmp('treePagesList').getStore().getNodeById(nodeID).data.text = newText;
Ext.getCmp('treePagesList').getStore().getNodeById(nodeID).set('text', newText);

Thanks for the help

tvanzoelen
20 Dec 2012, 5:01 AM
what is the displayField you have set on the treePanel?

noamway
20 Dec 2012, 6:05 AM
Default text field (text)

tvanzoelen
21 Dec 2012, 12:02 AM
Well doubt on my side but this is definitely the code



var node = tree.getStore().getNodeById(id);
node.set('text', 'Test');


setting the data property is not needed.

noamway
21 Dec 2012, 8:46 AM
You right, it was something wrong with my own code, that work for me:
node.set('text', String(newText));

Big thanks for the help :-)