View Full Version : refresh cause tree panel blank

May 29, 2020, 4:48 AM
Greeting ....

I use this code to refresh my tree ..

<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="Barang.aspx.cs" Inherits="WebApplication1.Setup.Barang" %>

<script runat="server">

public string RefreshMenu()
Ext.Net.NodeCollection nodes = this.BuildTree(null);
return nodes.ToJson();


<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">

var refreshTree = function (tree) {
success: function (result) {
var nodes = eval(result);
if (nodes.length > 0) {
else {


I get that code from Ext.Net example #/TreePanel/Basic/Refresh_Static_Tree/ (https://examples5.ext.net/#/TreePanel/Basic/Refresh_Static_Tree/)

and build tree using Ext.Net example #/TreePanel/Loaders/Direct_Method/ (https://examples5.ext.net/#/TreePanel/Loaders/Direct_Method/)

it look like


but after refresh using that code above, my tree become like this


is there any solution .... ???

Thank's ....

May 29, 2020, 4:08 PM
Hello @muhammadantoniussony!

The two examples depict situations that are fairly "mutually exclusive". In one hand, you have a tree that loads on demand. In the other hand, you have a refresh loading the full tree.

In order to attain a "refresh" behavior in an environment like a loader-based tree, you'd have to, instead of reloading everything, to remember which local nodes are expanded, unload everything and then reload from root to the point you were.

One approach to get the behavior you want is:

1. start by "unloading" the tree; so that when "refresh" is clicked, it returns to its initial state. So basically you reset the tree without a full page reload.
2. Then you will have to save the expanded nodes somewhere else (an array, or a temporary store, you name it)
3. traverse the list of expanded nodes, from root down, calling the corresponding node in the refreshed tree's .expand() method, and letting the direct method run (wait all the server trip -- your best bet is to bind the continuation of the process to the direct method's callback)
4. if a expanded node is not found, then the process should stop (because it means the node was removed from the fresh version of the tree).

So, basically, you have to reload and repeat the user steps to expand the tree.

For performance, you can pass the list of expanded nodes to the refresh method and have it return the whole expanded tree.

Using the approach from the first example you pointed (TreePanel > Basic > Refresh_Static_Tree (https://examples5.ext.net/#/TreePanel/Basic/Refresh_Static_Tree/)) only supports bringing the whole tree, which is something you probably don't want -- after all you load just a level of the tree for a reason.

Hope this helps!

May 30, 2020, 3:47 PM
Greeting ...

I add .expand() method on code behind

Ext.Net.Node root = new Ext.Net.Node();
root.Text = "RooT";
root.Expanded = true; /* --- add this make root.children to show, cause it hide on RooT --- */

Thank you ....