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

Hierarchical Grid If No childs Dont display Expand Button

3 Answers 56 Views
Grid
This is a migrated thread and some comments may be shown as answers.
umar
Top achievements
Rank 1
umar asked on 15 Nov 2011, 08:50 AM
I have hierarchical Grid .If i Dont have Childs Then it should Not show expand Button.How to do That.

3 Answers, 1 is accepted

Sort by
0
Pavlina
Telerik team
answered on 15 Nov 2011, 09:14 AM
Hi Umar,

How to achieve your goal is demonstrated in this help article:
http://www.telerik.com/help/aspnet-ajax/grid-hide-expand-collapse-images-when-no-records.html

Kind regards,
Pavlina
the Telerik team
If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the RadControls for ASP.NET AJAX, subscribe to their blog feed now
0
umar
Top achievements
Rank 1
answered on 15 Nov 2011, 10:51 AM
It Hides All Expand Buttons .Also Those who have the Chulds
0
Jayesh Goyani
Top achievements
Rank 2
answered on 15 Nov 2011, 11:47 AM
Hello,

public static void HideExpandColumnRecursive(GridTableView tableView)
    {
        GridItem[] nestedViewItems = tableView.GetItems(GridItemType.NestedView);
        foreach (GridNestedViewItem nestedViewItem in nestedViewItems)
        {
            foreach (GridTableView nestedView in nestedViewItem.NestedTableViews)
            {
                if (nestedView.Items.Count == 0)
                {
                    System.Web.UI.WebControls.TableCell cell = nestedView.ParentItem["ExpandColumn"];
 
                    if (cell.Controls.Count == 0)
                    {
                    }
                    else
                    {
                        cell.Controls[0].Visible = false;
                    }
                    nestedViewItem.Visible = false;
                }
                if (nestedView.HasDetailTables)
                {
                    HideExpandColumnRecursive(nestedView);
                }
            }
        }
    }
   
 
  protected void RadGrid1_PreRender(object sender, EventArgs e)
    {
        HideExpandColumnRecursive(RadGrid1.MasterTableView);
    }

Let me know if any concern.

Thanks,
Jayesh Goyani
Tags
Grid
Asked by
umar
Top achievements
Rank 1
Answers by
Pavlina
Telerik team
umar
Top achievements
Rank 1
Jayesh Goyani
Top achievements
Rank 2
Share this question
or