PDA

View Full Version : [CLOSED] [#243] Start Grid Groups Collapsed



bayoglu
May 17, 2013, 6:22 PM
Hello,

Even though I set StartCollapsed="true" for the Grouping feature of the grid panel, the groups are shown expanded after page load. Am I doing sth. wrong?

Sample code shared with this threat (http://forums.ext.net/showthread.php?24896-Sorting-grid-groups-based-on-external-data):



<%@ 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)
{
this.MyStore.DataSource = new List<object>
{
new {
ID = 1,
NameID = 1,
Value = 3
},
new {
ID = 2,
NameID = 1,
Value = 5
},
new {
ID = 3,
NameID = 1,
Value = 3
},
new {
ID = 4,
NameID = 1,
Value = 5
},
new {
ID = 5,
NameID = 2,
Value = 7
},
new {
ID = 6,
NameID = 2,
Value = 6
},
new {
ID = 7,
NameID = 2,
Value = 7
},
new {
ID = 8,
NameID = 2,
Value = 6
},
new {
ID = 9,
NameID = 3,
Value = 9
},
new {
ID = 10,
NameID = 3,
Value = 9
}
};
this.MyStore.DataBind();

this.NameStore.DataSource = new List<object>
{
new {
ID = 1,
Name = "Bond",
Priority = 3
},
new {
ID = 2,
Name = "James Bond",
Priority = 1
},
new {
ID = 3,
Name = "Jr. Bond",
Priority = 2
}
};
}
}
</script>
<script type="text/javascript">
function getGroupingText(NameID) {
var nameStore = App.NameStore;
var id = parseInt(NameID);
var storeItem = nameStore.getById(id);
var groupText = "Name: " + storeItem.get('Name') + " > Priority: " + storeItem.get('Priority');
return groupText;
}

</script>
<!DOCTYPE html>
<html>
<head id="Head1" runat="server">
<title>Ext.NET Examples</title>
</head>
<body>
<form id="Form1" runat="server">
<ext:ResourceManager ID="ResourceManager1" runat="server" SourceFormatting="True" />
<ext:Store ID="MyStore" runat="server" GroupField="NameID">
<Model>
<ext:Model ID="MyStoreModel" runat="server" IDProperty="ID">
<Fields>
<ext:ModelField Name="ID" Type="Int"></ext:ModelField>
<ext:ModelField Name="NameID" Type="Int"></ext:ModelField>
<ext:ModelField Name="Value" Type="Int" UseNull="true"></ext:ModelField>
</Fields>
</ext:Model>
</Model>
</ext:Store>
<ext:Store ID="NameStore" runat="server">
<Model>
<ext:Model ID="NameStoreModel" runat="server" IDProperty="ID">
<Fields>
<ext:ModelField Name="ID" Type="Int"></ext:ModelField>
<ext:ModelField Name="Name" Type="String"></ext:ModelField>
<ext:ModelField Name="Priority" Type="Int"></ext:ModelField>
</Fields>
</ext:Model>
</Model>
</ext:Store>
<ext:GridPanel ID="MyGrid" runat="server" StoreID="MyStore" MinHeight="200" Collapsible="false" Flex="1" Title="My Form" SelectionMemory="false">
<ColumnModel runat="server" ID="MyColumnModel">
<Columns>
<ext:Column ID="Name" runat="server" Text="Name" DataIndex="NameID" Align="Left" Flex="1">
</ext:Column>
<ext:Column ID="Value" runat="server" Text="Value" DataIndex="Value" Align="Left" Flex="1" Groupable="false">
</ext:Column>
</Columns>
</ColumnModel>
<Features>
<ext:Grouping ID="Grouping1" runat="server" HideGroupedHeader="true" StartCollapsed="true">
<GroupHeaderTpl ID="GroupHeaderTpl1" runat="server" Enabled="true">
<Functions>
<ext:JFunction Handler="return getGroupingText(NameID);" Name="testFn" Args="NameID">
</ext:JFunction>
</Functions>
<Html>
{[this.testFn(values.name)]}
</Html>
</GroupHeaderTpl>
</ext:Grouping>
</Features>
</ext:GridPanel>
</form>
</body>
</html>


Thanks.

Baidaly
May 17, 2013, 6:49 PM
Hello!

Thank you! Sencha already knows about this bug. We have created an issue to track this defect: https://github.com/extnet/Ext.NET/issues/243

Temporarily use the following listener for the GridPanel:



<Listeners>
<AfterRender Handler="this.getFeature('grouping').collapseAll();" Delay="10"></AfterRender>
</Listeners>

bayoglu
May 17, 2013, 7:08 PM
Hello @Baidaly,

Thanks for the quick response and the work-around.

Daniil
Jun 03, 2013, 3:57 PM
The issue appears to be fixed in SVN. The fix will go to the next release (v2.2.1 or v2.3).