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

Grid columns grouping configuration error

5 Answers 341 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Antonio
Top achievements
Rank 1
Antonio asked on 13 Nov 2012, 03:12 PM
Hello,

I have a grid with columns grouping, being created dynamically:

public static GridColumn AddColumn(this RadGrid grid, string column, int width, string headerText = null, string sortExpr = null, string colGroupName = null)
{
if (string.IsNullOrEmpty(headerText))
headerText = column;


var boundColumn = new GridBoundColumn();
grid.MasterTableView.Columns.Add(boundColumn);
boundColumn.DataField = column;
boundColumn.HeaderText = headerText;
boundColumn.UniqueName = column;
if (colGroupName != null)
{
boundColumn.ColumnGroupName = colGroupName;
boundColumn.AllowSorting = false;
}
else
{
if (string.IsNullOrEmpty(sortExpr))
sortExpr = column;
boundColumn.AllowSorting = false;
boundColumn.SortExpression = sortExpr;
}


return boundColumn;
}


public static GridColumnGroup AddColumnGroup(this RadGrid grid, string name, int width, string headerText, string parent = null)
{
var colGroup = new GridColumnGroup();
grid.MasterTableView.ColumnGroups.Add(colGroup);
colGroup.Name = name;
colGroup.HeaderText = headerText;
if (parent != null)
colGroup.ParentGroupName = parent;
return colGroup;
}
and in ascx.cs:
foreach (var indicator in ListIndicatori)
{
if (....)
{
List.AddColumn("Field_" + indicator.Id, 100, indicator.Denumire + "(" + indicator.UnitateMasura + ")");
DataTableSource.Columns.Add("Field_" + indicator.Id);
}
else
{
var groupName = "Group" + indicator.Id;
List.AddColumnGroup(groupName, 120, indicator.Denumire + "(" + indicator.UnitateMasura + ")");
List.AddColumn("Field_" + indicator.Id + "_LD", 40, "LD", colGroupName: groupName);
List.AddColumn("Field_" + indicator.Id + "_LQ", 40, "LQ", colGroupName: groupName);
List.AddColumn("Field_" + indicator.Id + "_VF", 40, "VF", colGroupName: groupName);


DataTableSource.Columns.Add("Field_" + indicator.Id + "_LD");
DataTableSource.Columns.Add("Field_" + indicator.Id + "_LQ");
DataTableSource.Columns.Add("Field_" + indicator.Id + "_VF");
}
}

where List is RadGrid declared in ascx file
I receive the error:
Invalid column group configuration! Column "Field_10_LQ" cannot be after column "Field_5"
The columns are not always the same (i.e Column "Field_53_LQ" cannot be after column "Field_7") and does not appears all the time, but I was not able to discover why and when (in which cases) it appears.
Any help will be appreciated!

Thanks,
Antonio

5 Answers, 1 is accepted

Sort by
0
Marin
Telerik team
answered on 16 Nov 2012, 10:49 AM
Hello,

 If you create column groups progrmatically this has to be done in the Page_Load event if the grid is already defined in the markup and in the Page_Init if you define the whole grid programatically. Also if change the group columns structure on postback you should clear the ColumnGroups collection first to make sure no old data is loaded from the ViewState.

Regards,
Marin
the Telerik team
If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the RadControls for ASP.NET AJAX, subscribe to their blog feed now.
0
Antonio
Top achievements
Rank 1
answered on 20 Nov 2012, 03:32 PM
Ok, I found the problem: i reordered the position of some columns and I saved grid configuration. Once I deleted configuration from database the problem disappeared. But I still have another one:

Error: TypeError: this.HeaderRow is undefined
Source File: http://localhost:7001/Telerik.Web.UI.WebResource.axd?_TSM_HiddenField_=scriptMgr_TSM&compress=1&_TSM_CombinedScripts_=%3b%3bTelerik.Web.UI%2c+Version%3d2012.2.912.40%2c+Culture%3dneutral%2c+PublicKeyToken%3d121fae78165ba3d4%3aro-RO%3a6aabe639-e731-432d-8e00-1a2e36f6eee0%3a58366029%3aa7e79140
Line: 3351

when I resize a column. This time is on client side
Any ideea?

Thanks,
Antonio
0
Marin
Telerik team
answered on 21 Nov 2012, 05:01 PM
Hello,

 Column resizing is currently not supported when you have multicolumn headers in the grid. We are working on adding support for this feature as well for the next official release of the controls.

Regards,
Marin
the Telerik team
If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the RadControls for ASP.NET AJAX, subscribe to their blog feed now.
0
Antonio
Top achievements
Rank 1
answered on 23 Nov 2012, 12:03 PM
Ok, I will look further for your releases.
Regarding first error, "Field_10_LQ" cannot be after column "Field_5", this seems to appear because my columns are dynamically added and are not always the same (depends on some category selections), so I don't think it appears because of grouping. So, I have to renounce to save grid configuration in this kind of lists.
0
Marin
Telerik team
answered on 27 Nov 2012, 09:45 AM
Hello,

 Yes, the error appears when the column groups configuration is not valid (for example there are overlapping column headers). You should make sure that each time the column groups are added dynamically the generated structure is a valid one and it does not violate the rules for consistent layout and also there aren't any settings left from previous configuration meaning that you should make sure the GridColumnsGroup collection is cleared and the ColumnGroup property of each column is empty before generating a new multi-column header structure.

Greetings,
Marin
the Telerik team
If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the RadControls for ASP.NET AJAX, subscribe to their blog feed now.
Tags
Grid
Asked by
Antonio
Top achievements
Rank 1
Answers by
Marin
Telerik team
Antonio
Top achievements
Rank 1
Share this question
or