Remove Expand/Collapse

2 posts, 0 answers
  1. SUBIN
    SUBIN avatar
    8 posts
    Member since:
    Jan 2013

    Posted 02 Feb 2013 Link to this post

    Hello,
    I wanna remove expand/collapse property when no child items in hierarchical grid.I wanna remove particular cell expand/collapse only
  2. Jayesh Goyani
    Jayesh Goyani avatar
    2733 posts
    Member since:
    May 2010

    Posted 03 Feb 2013 Link to this post

    Hello,

    public static void HideExpandColumnRecursive(GridDataItemCollection items)
            {
                foreach (GridDataItem item in items)
                {
                    if (item["ID"].Text == "1") // Put your condition here
                    {
                        foreach (GridTableView nestedViewItem in item.ChildItem.NestedTableViews)
                        {
                            if (nestedViewItem.Items.Count == 0)
                            {
                                System.Web.UI.WebControls.TableCell cell = nestedViewItem.ParentItem["ExpandColumn"];
     
                                if (cell.Controls.Count == 0)
                                {
                                }
                                else
                                {
                                    cell.Controls[0].Visible = false;
                                }
                                nestedViewItem.Visible = false;
                            }
                        }
                    }
                }
            }
     
        protected void Page_PreRender(object sender, EventArgs e)
            {
                HideExpandColumnRecursive(RadGrid1.MasterTableView.Items);
            }


    Thanks,
    Jayesh Goyani
Back to Top