PDA

View Full Version : How to refresh or re-render TreePanel ExtJS4?



shwetapro
14 Aug 2012, 3:31 AM
Hi,

I have a list of records in a tree panel ExtJS4.
I can delete a record through delete button below the treepanel. After the delete service is sent to the server, refreshed data is collected in treestore of the treepanel. But when I load the store through Ext.applyand then refresh the view of the treepanel, then too the tree is not refreshed, i.e. I can still see the deleted record.
The record gets removed from the panel when I re-login into the application, ie. tree is not getting refreshed.

Please find below code (I have tried all the below codes but the screen is not getting refreshed):

Ext.apply(plansPanel.getStore(), store);

Ext.apply(plansPanel, {
store: store
});

plansPanel.render();

plansPanel.getRootNode().collapse();
plansPanel.getRootNode().expand();

plansPanel.view.refresh();
plansPanel.view.render();

plansPanel.getView().refresh();
plansPanel.getView().render();

plansPanel.render();

plansPanel.getRootNode().collapse();
plansPanel.getRootNode().expand();

plansPanel.render();


Help appreciated.

Thanks,
Shweta

friend
14 Aug 2012, 4:35 AM
Reloading your TreePanel's store should be as easy as:



yourTreePanel.getStore().load();


It sounds as if you're having one of two problems: 1.) Your browser is caching JSON responses or 2.) the delete is failing server-side.

I'd eliminate possibility #2 first by sprinkling a little logging code in the server-side method which performs the delete and use Firefox/Firebug or Chrome Developer tools to inspect the response to the client to ensure that data for the deleted record is not present.

shwetapro
14 Aug 2012, 5:00 AM
Thanks for replying friend.

I've already tried it. But treestore's load method throws error. :s (a is undefined)

Moreover browser isn't caching the JSON response, neither is the server request failing.

As soon as the server request gets fired, I debugged the code on server class and store data on Firebug. In both cases the data is correct and updated.

Help appreciated.

Thanks,
Shweta

scottmartin
14 Aug 2012, 9:16 AM
Are there any errors in the console?
What is your header/response .. any errors on the server? do you get a response?

This should be straight forward.

Scott.

shwetapro
14 Aug 2012, 7:58 PM
Thanks for replying Scott martin.

There isn't any error on the console. And to delete a record, the command fired does not gives back any response. It only gives a success or error code stating whether the record is deleted or not. In my case it gives a success code.

To retrieve the fresh data I had fired the same command which I initially did to load the tree panel. After this command is fired, I can see the new data in store as well as in tree but tree does not gets refreshed somehow.

Help appreciated.

Thanks,
Shweta