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

Self Hierarchy Grid Title CommandItemTemplate

1 Answer 21 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Sunny
Top achievements
Rank 1
Sunny asked on 21 Oct 2009, 09:36 PM

I have a Self-referencing Hierarchy grid and I want add Title (and some controls to that). I am using CommandItemTemplate inside MasterTableview for that. With this I am able to add title to the grid, but I am getting titles for nested row also.. How to avoid that?

I am using the code in the sample below,
http://demos.telerik.com/aspnet-ajax/grid/examples/hierarchy/selfreferencing/defaultcs.aspx

1 Answer, 1 is accepted

Sort by
0
Veli
Telerik team
answered on 27 Oct 2009, 09:04 AM
Hello TelNew,

If using  the example from the demo, you can add:

nestedView.GetItems(GridItemType.CommandItem)[0].Visible = false;

to your HideExpandCollapseColumnRecursive() method:

public void HideExpandColumnRecursive(GridTableView tableView)
{
    GridItem[] nestedViewItems = tableView.GetItems(GridItemType.NestedView);
    foreach (GridNestedViewItem nestedViewItem in nestedViewItems)
    {
        foreach (GridTableView nestedView in nestedViewItem.NestedTableViews)
        {
            nestedView.Style["border"] = "0";
 
            //HERE
            nestedView.GetItems(GridItemType.CommandItem)[0].Visible = false;
 
            Button MyExpandCollapseButton = (Button)nestedView.ParentItem.FindControl("MyExpandCollapseButton");
            if (nestedView.Items.Count == 0)
            {
                if (MyExpandCollapseButton != null)
                {
                    MyExpandCollapseButton.Style["visibility"] = "hidden";
                }
                nestedViewItem.Visible = false;
            }
            else
            {
                if (MyExpandCollapseButton != null)
                {
                    MyExpandCollapseButton.Style.Remove("visibility");
                }
            }
 
            if (nestedView.HasDetailTables)
            {
                HideExpandColumnRecursive(nestedView);
            }
        }
    }
}


Sincerely yours,
Veli
the Telerik team

Instantly find answers to your questions on the new Telerik Support Portal.
Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
Tags
Grid
Asked by
Sunny
Top achievements
Rank 1
Answers by
Veli
Telerik team
Share this question
or