I'm having a problem with RadGrid column filtering. I have a grid that I have set AutoGenerateColumns = False, and I am dynamically building the bound columns in the code-behind... an example of one of the columns follows:
My RadGrid is bound to an ObjectDataSource which exposes a DataTable as follows:
The problem occurs when I try to do client-side drag-and-drop reordering of the columns, with AJAX and filtering enabled. I end up getting a Javascript error: "Error: Sys.ArgumentException: Value must not be null for Controls and Behaviors. Parameter name: element"
However, if I set AutoGenerateColumns = True and bypass my dynamic column generation code, everything works OK.
My question is... what am I missing when I create my own columns dynamically? What properties are being set when AutoGenerateColumns = True that I need to reproduce dynamically in order to allow this to work?
Thanks in advance.
case "Numeric": |
GridNumericColumn numericCol = new GridNumericColumn(); |
RadGrid1.MasterTableView.Columns.Add(numericCol); |
numericCol.HeaderText = GridSchema.ColumnHeadersSplit[i].ToString(); |
numericCol.DataField = GridSchema.ColumnNamesSplit[i].ToString(); |
numericCol.UniqueName = GridSchema.ColumnNamesSplit[i].ToString(); |
numericCol.Reorderable = true; |
numericCol.ConvertEmptyStringToNull = true; |
numericCol.DataFormatString = GridSchema.ColumnFormatsSplit[i].ToString(); |
numericCol.FooterAggregateFormatString = GridSchema.ColumnFormatsSplit[i].ToString(); |
if (GridSchema.ColumnAggregateFormatSplit[i].ToString() == string.Empty) |
{ numericCol.Aggregate = (GridAggregateFunction)Enum.Parse(typeof(GridAggregateFunction), "None"); } |
else |
{ numericCol.Aggregate = (GridAggregateFunction)Enum.Parse(typeof(GridAggregateFunction), GridSchema.ColumnAggregateFormatSplit[i].ToString()); } |
numericCol.AllowFiltering = (Boolean)Convert.ToBoolean(Convert.ToInt32(GridSchema.ColumnAllowFilteringSplit[i].ToString())); |
numericCol.Groupable = (Boolean)Convert.ToBoolean(Convert.ToInt32(GridSchema.ColumnAllowGroupingSplit[i].ToString())); |
numericCol.AllowSorting = (Boolean)Convert.ToBoolean(Convert.ToInt32(GridSchema.ColumnAllowSortingSplit[i].ToString())); |
numericCol.Visible = (Boolean)Convert.ToBoolean(Convert.ToInt32(GridSchema.ColumnVisibleSplit[i].ToString())); |
break; |
My RadGrid is bound to an ObjectDataSource which exposes a DataTable as follows:
<telerik:RadGrid ID="RadGrid1" runat="server" DataSourceID="ObjectDataSource1" GridLines="None" |
AllowFilteringByColumn="True" AutoGenerateColumns="False"> |
<MasterTableView DataSourceID="ObjectDataSource1"> |
<RowIndicatorColumn> |
<HeaderStyle Width="20px"></HeaderStyle> |
</RowIndicatorColumn> |
<ExpandCollapseColumn> |
<HeaderStyle Width="20px"></HeaderStyle> |
</ExpandCollapseColumn> |
</MasterTableView> |
<ClientSettings AllowColumnsReorder="True" ColumnsReorderMethod="Reorder"> |
</ClientSettings> |
<FilterMenu EnableTheming="True"> |
<CollapseAnimation Type="OutQuint" Duration="200"></CollapseAnimation> |
</FilterMenu> |
</telerik:RadGrid> |
The problem occurs when I try to do client-side drag-and-drop reordering of the columns, with AJAX and filtering enabled. I end up getting a Javascript error: "Error: Sys.ArgumentException: Value must not be null for Controls and Behaviors. Parameter name: element"
However, if I set AutoGenerateColumns = True and bypass my dynamic column generation code, everything works OK.
My question is... what am I missing when I create my own columns dynamically? What properties are being set when AutoGenerateColumns = True that I need to reproduce dynamically in order to allow this to work?
Thanks in advance.