This is a migrated thread and some comments may be shown as answers.

Refreshing RadTreeView bound to the generic List<> when use Load On Demand feature

3 Answers 72 Views
TreeView
This is a migrated thread and some comments may be shown as answers.
db
Top achievements
Rank 1
db asked on 21 May 2010, 09:13 AM
Hi ,

I have a RadTreeView Bound to the generic List<Category>. Nodes are loaded on Demad.

I have the code :

protected

 

void Page_Load(object sender, EventArgs e)  

 

 

    if (!Page.IsPostBack) 

    { 

        LoadRootNodes(

TreeNodeExpandMode.ServerSideCallBack);  

 

 

    }

    RadTreeView1.DataBind();

}

and 

 

protected

 

 

void RadTreeView_NodeExpand(object sender, RadTreeNodeEventArgs e)  

 

 

{

 

 

    PopulateNodeOnDemand(e,

TreeNodeExpandMode.ServerSideCallBack);

 

 

}

so when I delete Category from the RadTreeView (the delete button is nested in the NodeTemplate),  fisrt I call method to delete the category from the database : (CategoriesData.Delete(SelectedNode.Value)) and after that remove the  node from the RadTreeView.
(SelectedNode.Remove)
But when I press the refresh Button of the Browser after the node was removed from the TreeView, it appears again.So my question is how I can Refresh the TreeView   on delete operation,  when   i use Load-on demand feature and NodeTemplate.
.

Best Regards Deyana

 

 

 

 

 

 

3 Answers, 1 is accepted

Sort by
0
Nikolay Tsenkov
Telerik team
answered on 26 May 2010, 02:16 PM
Hello didi borisova,

I have tried to reproduce this issue, but I was not able to.
Actually, at first I got the same effect, but it was my mistake - I didn't assigned the handler for the button on every postback (so it's assigned only when it's loaded for first time).

Please, check if your event-handler is being fired.
If this is not the problem, please post a simple markup and code-behind that reproduces your problem.

Hope this is helpful for you!

Regards,
Nikolay Tsenkov
the Telerik team

Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items.
0
db
Top achievements
Rank 1
answered on 26 May 2010, 03:31 PM

protected

 

void Page_Load(object sender, EventArgs e)

 

{

 

    if (!Page.IsPostBack)

 

    {

        LoadRootNodes(

TreeNodeExpandMode.ServerSideCallBack);

 

    }

 

    }

 

protected

 

void RadTreeView_NodeExpand(object sender, RadTreeNodeEventArgs e)

 

{

    PopulateNodeOnDemand(e,

TreeNodeExpandMode.ServerSideCallBack);

 

}

 

private

 

void PopulateNodeOnDemand(RadTreeNodeEventArgs e, TreeNodeExpandMode expandMode)

 

{

 

i    nt parentID = int.Parse(e.Node.Value);

 

 

    List<Category> categories = CategoriesData.GetImmediateChildren(parentID);

 

 

 

    foreach (Category category in categories)

 

    {

 

        RadTreeNode node = new RadTreeNode();

 

        SetNodeProperties(node, expandMode, category);

 

        e.Node.Nodes.Add(node);

    }

    e.Node.Expanded =

true;    

 

}

 

protected

 

void btnDelete_Click(object sender, EventArgs e)

 

{

          

 

    IList

 

<RadTreeNode> checkedNodes = RadTreeView1.CheckedNodes;

 

 

 

    foreach(RadTreeNode node in checkedNodes)

 

    {

 

        int categoryID = int.Parse(node.Value);

 

        if(

CategoriesData.Delete(categoryID))         

 

            RadTreeView1.Nodes.Remove(node);

       

 

    

 

   }

 

     // to refresh TreeView(even when f5 is pressed)
     RadTreeView1.Nodes.Clear();

 

     LoadRootNodes(

TreeNodeExpandMode.ServerSideCallBack);/
    // here I must expand TreeView(I need to expand parent node of the deleted node )

 

 

}

It looks work properly.But when I press F5(refresh button), the deleted node apprears again(if I do not invoke  :

    RadTreeView1.Nodes.Clear();

     LoadRootNodes(TreeNodeExpandMode.ServerSideCallBack);/

).
Only When the page is requested again then the deleted node is misssing(becouse LoadRootNodes is executed and categories are loaded from the database).
So in this situation  to refresh TreeView after delete operation I invoke LoadRootNodes () method again, then nodes will be loaded from the database  and  the deleted node does not appear.
But the problem here is when I delete child node, Then the TreeView is not expanded and the user must expand the TreeView manually to see the changes after delete operation(it is boring when deleted node has too many parents).So How I can Expand TreeView ( I need to expand parent node of the deleted node  )  when Load On demand feature is used.

0
Nikolay Tsenkov
Telerik team
answered on 31 May 2010, 09:05 AM
Hello db,

I couldn't reproduce the issue you are having.
Please open a support ticket and attach a simple project illustrating this problem and I will do my best to resolve it.

Regards,
Nikolay Tsenkov
the Telerik team

Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items.
Tags
TreeView
Asked by
db
Top achievements
Rank 1
Answers by
Nikolay Tsenkov
Telerik team
db
Top achievements
Rank 1
Share this question
or