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

Retrieve data from treeview

4 Answers 76 Views
TreeView
This is a migrated thread and some comments may be shown as answers.
wilson
Top achievements
Rank 1
wilson asked on 12 Sep 2011, 06:47 AM
Hi , I have a treeview call tvAllCategory and it contain 2 header data field(id, App_SubCategory)
how do I retrieve back treeview Item and check if it has match with the item i key in? What I trying to do is to check the item delete in my gridview whether is exist in treeview or not, if didn't exist then need to add in back to the treeview.
below is my code

   private void gvFavorite_Deleting(object sender, Telerik.Windows.Controls.GridViewDeletingEventArgs e)
        {
            itemsToBeDeleted = e.Items;
            foreach (var itm in itemsToBeDeleted)
            {
                               
         received null         var mytvList = tvAllCategory.ItemsSource as MyFavorite.SilverLightService.tvCategoryList;
          error here       // mytvList.App_SubCategory.Contains(itm.ToString());

                   gvFavorite.Items.Remove(itm);
              }
}             


For your information below my tree hierarchy
HEADER(ID,App_SubCategory)
CHILD(ID,App_SubCategory,items)

4 Answers, 1 is accepted

Sort by
0
Maya
Telerik team
answered on 14 Sep 2011, 03:51 PM
Hi Wilson,

Actually, you will not be able to work with the Items collection directly while RadGridView is in use. You may try something like follows:

IList<Player> gridViewSource = this.playersGrid.ItemsSource as IList<Player>;

and remove/add items from/to the gridViewSouce. 
Furthermore, I tested the issue you reported - the fact that the ItemsSource of RadTreeView is null and I was not able to reproduce it. Please see the sample project attached and let me know whether you can get the same behavior on it.
   Kind regards,
Maya
the Telerik team

Explore the entire Telerik portfolio by downloading the Ultimate Collection trial package. Get it now >>

0
wilson
Top achievements
Rank 1
answered on 15 Sep 2011, 11:08 AM
Not sure is it work or not, but now I'm trying to add in some items into the treeview but not able to get around, could you do me a favor show me some example? how to get the treeview header B and add new child into it? Thanks in advance.

Header
A
    - Child1
    - Child2
B
    - Child1
    - Child2
0
wilson
Top achievements
Rank 1
answered on 15 Sep 2011, 11:40 AM
Hi,
  I was successfully add in child item but could you show me a way on how to create new header for the tree view? how to create new header called C and bind back to the tree view?

Header
A
    - Child1
    - Child2
B
    - Child1
    - Child2
0
Petar Mladenov
Telerik team
answered on 20 Sep 2011, 11:40 AM
Hi Wilson,

 Please check out the modified solution and note that an ItemTempalte is used in the RadTreeView. This is the way to bind the Name of the Player two way so that a dynamic change in the Player reflects the UI. Please let us know if you need further assistance.

Regards,
Petar Mladenov
the Telerik team

Explore the entire Telerik portfolio by downloading the Ultimate Collection trial package. Get it now >>

Tags
TreeView
Asked by
wilson
Top achievements
Rank 1
Answers by
Maya
Telerik team
wilson
Top achievements
Rank 1
Petar Mladenov
Telerik team
Share this question
or