PDA

View Full Version : [CLOSED] Grouping Feature, trigger in Code Behind (VB.NET)



sisa
Nov 07, 2014, 10:22 AM
Hi all

I need to trigger a Grouping Feature in Code Behind.

I got this Grouping on my GridPanel:

<Features>
<ext:Grouping ID="grpDeclaration" runat="server" HideGroupedHeader="False" StartCollapsed="true" />
</Features>

I tried to call the Feature after the Data Binding


Dim grpFeature As Ext.Net.Grouping = CType(gridDeclarationVersion.Features(0), Grouping)
grpFeature.collapseAll()

But, that doesn't do anything :-(

Any Hint
Peter

Daniil
Nov 07, 2014, 11:34 AM
Hi Peter,

I think this

grpFeature.collapseAll()
should throw a compile error, because there is no such the method. It is case-sensitive and it should be ".CollapseAll()".

Here is a working example.

Example

<%@ Page Language="C#" %>

<script runat="server">
protected void Page_Load(object sender, EventArgs e)
{
if (!X.IsAjaxRequest)
{
Store store = this.GridPanel1.GetStore();
store.DataSource = new object[]
{
new object[] { "group1", "1", "1" },
new object[] { "group1", "11", "11" },
new object[] { "group1", "111", "111" },
new object[] { "group2", "2", "2" },
new object[] { "group2", "22", "22" },
new object[] { "group2", "222", "222" }
};
}
}

protected void CollapseAll(object sender, DirectEventArgs e)
{
this.Grouping1.CollapseAll();
}
</script>

<!DOCTYPE html>

<html>
<head runat="server">
<title>Ext.NET v2 Example</title>
</head>
<body>
<form runat="server">
<ext:ResourceManager runat="server" />

<ext:Button runat="server" Text="Collapse all" OnDirectClick="CollapseAll" />

<ext:GridPanel ID="GridPanel1" runat="server">
<Store>
<ext:Store runat="server" GroupField="groupId">
<Model>
<ext:Model runat="server">
<Fields>
<ext:ModelField Name="groupId" />
<ext:ModelField Name="test1" />
<ext:ModelField Name="test2" />
</Fields>
</ext:Model>
</Model>
</ext:Store>
</Store>
<ColumnModel runat="server">
<Columns>
<ext:Column runat="server" Text="GroupId" DataIndex="groupId" />
<ext:Column runat="server" Text="Test1" DataIndex="test1" />
<ext:Column runat="server" Text="Test2" DataIndex="test2" />
</Columns>
</ColumnModel>
<Features>
<ext:Grouping ID="Grouping1" runat="server" />
</Features>
</ext:GridPanel>
</form>
</body>
</html>