Hide RadGrid data and header at runtime

7 posts, 0 answers
  1. Kerry
    Kerry avatar
    61 posts
    Member since:
    Nov 2008

    Posted 29 Jun 2009 Link to this post

    Hello, I am populating a radgrid on the NeedDatasource event, the columns are AutoGenerated, I require that some columns be hidden at runtime which I am doing on the ItemDataBound Event using e.Item.Cells[2].Visible = false;.  THis works great however the problem is that the associated column header is not being hidden so I end up with 4 data columns and 8 column headers. I'm I using the wrong event or wrong property to hide the columns.

    Thanks

     

  2. Princy
    Princy avatar
    17421 posts
    Member since:
    Mar 2007

    Posted 29 Jun 2009 Link to this post

    Hi,

    It  would be wise to hide the entire column rather than hiding cell wise.You can use the following code"

    protected void RadGrid1_ColumnCreated(object sender, GridColumnCreatedEventArgs e) 
        { 
            RadGrid1.MasterTableView.GetColumn("ColumnUniqueName").Visible = false
          
        }  
     

    Here  ColumnUniqueName is the UniqueName of your column.
    Princy


  3. UI for ASP.NET Ajax is Ready for VS 2017
  4. Kerry
    Kerry avatar
    61 posts
    Member since:
    Nov 2008

    Posted 29 Jun 2009 Link to this post

    Thanks for your response, however when I execute your suggestion I get
    An unhandled exception of type 'System.StackOverflowException' occurred in mscorlib.dll


    THanks
  5. Kerry
    Kerry avatar
    61 posts
    Member since:
    Nov 2008

    Posted 29 Jun 2009 Link to this post

    FYI, I followed the above suggestion on the PreRender event and it works well...Thank you.
  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

    }
  7. Princy
    Princy avatar
    17421 posts
    Member since:
    Mar 2007

    Posted 27 Aug 2013 Link to this post

    Hi Waseem,

    Please try the following code snippet to hide the header of a column.

    JS:
    <script type="text/javascript">
       function OnColumnCreated() {
          switch (column.get_uniqueName()) {
             case "ColumnUniqueName":              
               column.get_element().innerHTML = ""; //setting HeaderText to Empty            
               break;
            }
        }
    </script>

    Thanks,
    Princy
  8. Karguvelrajan
    Karguvelrajan avatar
    2 posts
    Member since:
    Oct 2016

    Posted 25 Oct Link to this post

    Step : 1 Set ShowHeader false in Redgrid and MasterTableView.
    Step : 2  Set below things in Column
    <telerik:GridTemplateColumn UniqueName="Attribute" HeaderText="" AllowFiltering="false" AllowSorting="false">
Back to Top
UI for ASP.NET Ajax is Ready for VS 2017