Apr 24, 2014, 2:21 PM
Problem with dynamic column header grouping
Hello everybody,
I have been using Ext.Net 1.0 for more than a year and I have found plenty of help in this forum, but I couldn't find anything about this so here is my thread.
I have been tearing my hair out with dynamic Column Header Grouping for days, until I somewhat narrowed down the problem. Basically, I can successfully create them in Page_Load, but it was impossible for me to do so from any other Ajax request, like a DirectMethod. Here I provide you with a very simple page to reproduce the problem:
I am using this Ext.Net version in a huge project in my job, so using the latest version is not an option for now (we had to do a lot of effort when we migrated from Coolite to 1.5 and we don't have time to do that kind of work again).
Any help will be greatly appreciated.
Thanks and regards,
Andrew
PS: My Ext.Net.dll is version 1.0.0.34577. Is that the version for 1.5?
I have been using Ext.Net 1.0 for more than a year and I have found plenty of help in this forum, but I couldn't find anything about this so here is my thread.
I have been tearing my hair out with dynamic Column Header Grouping for days, until I somewhat narrowed down the problem. Basically, I can successfully create them in Page_Load, but it was impossible for me to do so from any other Ajax request, like a DirectMethod. Here I provide you with a very simple page to reproduce the problem:
<%@ Page Language="C#" %>
<%@ Register Assembly="Ext.Net" Namespace="Ext.Net" TagPrefix="ext" %>
<script runat="server">
protected void Page_Load(object sender, EventArgs e)
{
if (!X.IsAjaxRequest)
{
PrepareGrid(myGrid, true);
}
}
[DirectMethod]
public void OnClick(object sender, DirectEventArgs e)
{
PrepareGrid(myGrid2, false);
btnPrepare.Disabled = true;
}
private void PrepareGrid(GridPanel grid, bool fromPageLoad)
{
var columns = new string[] { "Text 1", "Number 1", "Text 2", "Number 2", "End Column" };
foreach (string col in columns)
{
Column newCol = new Column { Header = col };
grid.ColumnModel.Columns.Add(newCol);
if (!fromPageLoad)
{
// Why is this necessary when not run from Page_Load?
grid.AddColumn(newCol);
}
}
var headerGroupRow = new HeaderGroupRow();
var headerGroups = new[] { new { Header = "Date", Span = 2 }, new { Header = "Group 1", Span = 2 },
new { Header = "Group 2", Span = 2}, new { Header = "", Span = 1}};
foreach (var header in headerGroups)
{
headerGroupRow.Columns.Add(new HeaderGroupColumn
{
Header = header.Header,
Align = Alignment.Center,
ColSpan = header.Span
});
}
grid.View[0].HeaderGroupRows.Add(headerGroupRow);
}
</script>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head id="Head1" runat="server">
<title>Dynamic Grid Column Header Grouping Problem</title>
</head>
<body>
<ext:ResourceManager ID="ResourceManager1" runat="server" />
<h1>Dynamic Grid Column Header Grouping Problem</h1>
<cnet:StoreTable ID="strEmpty" runat="server" />
<ext:GridPanel ID="myGrid" runat="server" StoreID="strEmpty" Height="200" Title="Built in Page_Load">
<ColumnModel runat="server">
<Columns>
<ext:Column Header="Day" />
<ext:Column Header="Time" />
</Columns>
</ColumnModel>
<View>
<ext:GroupingView>
<HeaderGroupRows>
</HeaderGroupRows>
</ext:GroupingView>
</View>
</ext:GridPanel>
<ext:Button runat="server" ID="btnPrepare" Text="Prepare Grid">
<DirectEvents>
<Click OnEvent="OnClick" />
</DirectEvents>
</ext:Button>
<ext:GridPanel ID="myGrid2" runat="server" StoreID="strEmpty" Height="200" Title="Built in OnClick">
<ColumnModel runat="server">
<Columns>
<ext:Column Header="Day" />
<ext:Column Header="Time" />
</Columns>
</ColumnModel>
<View>
<ext:GroupingView>
<HeaderGroupRows>
</HeaderGroupRows>
</ext:GroupingView>
</View>
</ext:GridPanel>
</body>
</html>
As you can see, the first grid is built perfectly but the second one is not. The PrepareGrid method, when called from Page_Load, works ok but not from the OnClick event. A second issue but less severe is the need to add the column in two places (in ColumnModel and with AddColumn method) when using the OnClick event.I am using this Ext.Net version in a huge project in my job, so using the latest version is not an option for now (we had to do a lot of effort when we migrated from Coolite to 1.5 and we don't have time to do that kind of work again).
Any help will be greatly appreciated.
Thanks and regards,
Andrew
PS: My Ext.Net.dll is version 1.0.0.34577. Is that the version for 1.5?
Last edited by ALobpreis; Apr 28, 2014 at 2:29 PM.