View Full Version : [CLOSED] Keep selection after reloading a node
Daniil
Jun 18, 2012, 5:13 PM
Hi,
There is no such built-in functionality. Though, I think it should not be a problem to implement it.
I would save the selected nodes before reloading and restore them after.
Ok Danill, please mark it as resolved. if you want i can post my solution to achieve it
Daniil
Jun 18, 2012, 6:01 PM
Sure, it would be good and can help someone (us as well) on the forums in the future. So, if you wish to share, it would be appreciated.
Daniil
Jun 18, 2012, 7:37 PM
Thanks for sharing, looks good.
Here is another approach.
Example
var reloadRoot = function () {
var tree = App.TreePanel2,
store = tree.getStore(),
options = {
node : tree.getRootNode()
},
sm = tree.getSelectionModel(),
selectedId;
if (sm.hasSelection()) {
selectedId = sm.getSelection()[0].getId();
Ext.apply(options, {
callback : function () {
var node = this.store.getNodeById(this.idToSelect);
if (node) {
this.sm.select(node);
}
},
scope : {
store : store,
sm : sm,
idToSelect : selectedId
}
});
}
store.load(options);
};
RCN
Jun 19, 2012, 12:38 PM
Thank you Danill.
Powered by vBulletin® Version 4.2.3 Copyright © 2019 vBulletin Solutions, Inc. All rights reserved.