PDA

View Full Version : [CLOSED] Keep selection after reloading a node



RCN
Jun 18, 2012, 4:49 PM

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.

RCN
Jun 18, 2012, 5:52 PM
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.

RCN
Jun 18, 2012, 6:25 PM

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.