Hi there.
This is my first trip with RadControls. I've created an usercontrol, which shows a Grid. My datasource is a DataTable, wich is populated on NeedDataSource event. I have to dynamically generate all columns of DataTable at runtime, so my ASCX file is pretty poor:
Also i need to group data. Therefore, i add columnbound on codebehind. Here is the important part of NeedDataSource
All works fine and the output is really pretty. But if i collapse one group, all column headers will be lost. I've also implemented export to Excel and PDF. It generates a file, but there are much more columns and some values are System.Data.DataRowView. Maybe it's the same reason?
Please advise me. Thanks
This is my first trip with RadControls. I've created an usercontrol, which shows a Grid. My datasource is a DataTable, wich is populated on NeedDataSource event. I have to dynamically generate all columns of DataTable at runtime, so my ASCX file is pretty poor:
<TELERIK:RADGRID ID="RadGrid1" RUNAT="server" ALLOWSORTING="true"> |
</TELERIK:RADGRID> |
Also i need to group data. Therefore, i add columnbound on codebehind. Here is the important part of NeedDataSource
RadGrid1.DataSource = table; |
RadGrid1.GroupingEnabled = true; |
RadGrid1.AutoGenerateColumns = false; |
GridBoundColumn boundcolumn; |
foreach (DataColumn column in table.Columns) |
{ |
if (column.ColumnName == "Name") |
{ |
continue; |
} |
boundcolumn = new GridBoundColumn(); |
boundcolumn.DataField = column.ColumnName; |
boundcolumn.HeaderText = column.ColumnName; |
RadGrid1.MasterTableView.Columns.Add(boundcolumn); |
} |
GridGroupByExpression expression = new GridGroupByExpression(); |
GridGroupByField groupbyfield = new GridGroupByField(); |
groupbyfield.FieldName = "Name"; |
groupbyfield.HeaderText = " "; |
groupbyfield.HeaderValueSeparator = string.Empty; |
groupbyfield.FormatString = "{0}"; |
expression.SelectFields.Add(groupbyfield); |
groupbyfield = new GridGroupByField(); |
groupbyfield.FieldName = "Name"; |
expression.GroupByFields.Add(groupbyfield); |
RadGrid1.MasterTableView.GroupByExpressions.Add(expression); |
RadGrid1.EnableViewState = true; |
All works fine and the output is really pretty. But if i collapse one group, all column headers will be lost. I've also implemented export to Excel and PDF. It generates a file, but there are much more columns and some values are System.Data.DataRowView. Maybe it's the same reason?
Please advise me. Thanks