Hide Header of DetailsTable in Hierarchy RadGrid

5 posts, 0 answers
  1. Surander
    Surander avatar
    3 posts
    Member since:
    Feb 2011

    Posted 05 Feb 2011 Link to this post

    Hi All,
      I have Three level Hierarchy RadGrid.
      I have to display the grid  all records(master or details table) expended mode.
      And its working fine by enabling property of master & detailTables HierarchyDefaultExpanded="true"
      But problem is i want to hide the "Header of detailsTables" if there is no child records in any level.

    Any Suggestion?

    Thanks,
    Surander
  2. Princy
    Princy avatar
    17421 posts
    Member since:
    Mar 2007

    Posted 06 Feb 2011 Link to this post

    Hello Surander,

    Try the following code snippet to hide the header when there is no record in detail grid.

    C#:
    protected void RadGrid1_PreRender(object sender, EventArgs e)
       {
           foreach (GridDataItem item in RadGrid1.Items)
           {
               if (item.Expanded)
               {
                   GridTableView tableView = (GridTableView)item.ChildItem.NestedTableViews[0];
                   if (tableView.Items.Count == 0)
                   {
                       tableView.ShowHeader = false;
                   }
                   foreach (GridDataItem childitem in tableView.Items)
                   {
                       if (childitem.Expanded)
                       {
                           GridTableView childtableView = (GridTableView)childitem.ChildItem.NestedTableViews[0];
                           if (childtableView.Items.Count == 0)
                           {
                               childtableView.ShowHeader = false;
                           }
                       }
                   }
               }
           }
         }

    Thanks,
    Princy.
  3. UI for ASP.NET Ajax is Ready for VS 2017
  4. Surander
    Surander avatar
    3 posts
    Member since:
    Feb 2011

    Posted 07 Feb 2011 Link to this post

    Hi Princy,
    Thanks for you help but its not working for me. I am getting error:

    Object reference not set to an instance of an object.


    on line
    GridTableView tableView = (GridTableView)item.ChildItem.NestedTableViews[0];

    And line
    GridTableView childtableView = (GridTableView)childitem.ChildItem.NestedTableViews[0];
                           

  5. Surander
    Surander avatar
    3 posts
    Member since:
    Feb 2011

    Posted 07 Feb 2011 Link to this post

    Hi,
    I got it by setting property of DetailTables -> GridTableView ShowHeadersWhenNoRecords="false".

    Thanks
    Surander
  6. <span>w</span>
    <span>w</span> avatar
    84 posts
    Member since:
    Jun 2012

    Posted 26 Aug 2013 Link to this post

    How to hide header on specific column in Radgrid in javascript?
    I don't want to use table.hideColumn(column.get_element().cellIndex);

     function PrintRadGrid() {
                    var radGrid = $find('<%= RadGrid1.ClientID %>');
                    var table = radGrid.get_masterTableView();
                    var column = table.getColumnByUniqueName("CkboxDelKey");
                    
                    var masterTable = $find("<%=RadGrid1.ClientID%>").get_masterTableView();
                    for (var row = 0; row < masterTable.get_dataItems().length; row++) {
                        var str = masterTable.getCellByColumnUniqueName(masterTable.get_dataItems()[row], "CkboxDelKey").innerHTML;
                        if (str.indexOf("<nobr>") != -1) {
                            masterTable.getCellByColumnUniqueName(masterTable.get_dataItems()[row], "CkboxDelKey").style.display = 'none';
                        }
                    }

    //hide header code
    //Code here

    }
Back to Top
UI for ASP.NET Ajax is Ready for VS 2017