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

Hide RadGrid data and header at runtime

6 Answers 174 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Kerry
Top achievements
Rank 1
Kerry asked on 29 Jun 2009, 05:16 AM
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

 

6 Answers, 1 is accepted

Sort by
0
Princy
Top achievements
Rank 1
answered on 29 Jun 2009, 07:30 AM
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


0
Kerry
Top achievements
Rank 1
answered on 29 Jun 2009, 02:57 PM
Thanks for your response, however when I execute your suggestion I get
An unhandled exception of type 'System.StackOverflowException' occurred in mscorlib.dll


THanks
0
Kerry
Top achievements
Rank 1
answered on 29 Jun 2009, 03:48 PM
FYI, I followed the above suggestion on the PreRender event and it works well...Thank you.
0
Waseem
Top achievements
Rank 1
answered on 26 Aug 2013, 07:54 PM
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

}
0
Princy
Top achievements
Rank 1
answered on 27 Aug 2013, 06:23 AM
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
0
Karguvelrajan
Top achievements
Rank 1
answered on 25 Oct 2016, 06:26 AM
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">
Tags
Grid
Asked by
Kerry
Top achievements
Rank 1
Answers by
Princy
Top achievements
Rank 1
Kerry
Top achievements
Rank 1
Waseem
Top achievements
Rank 1
Karguvelrajan
Top achievements
Rank 1
Share this question
or