PDA

View Full Version : [CLOSED] grouping summary problem?



tobros
Sep 22, 2013, 7:51 AM
I want to get average score group by grade, such as http://examples2.ext.net/#/GridPanel/Plugins/GroupingSummary/,
I wrote a simple test case, but not work, please check for me , is there sth wrong or miss?


<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="WebForm11.aspx.cs" Inherits="TobrosCWT.test.WebForm11" %>

<!DOCTYPE html>

<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title></title>
<script type="text/javascript" runat="server">
protected void Page_Load(object sender, EventArgs e)
{
if (!X.IsAjaxRequest)
{
store1.DataSource = new object[]
{
new object[]{"学生1",30,1},
new object[]{"学生2",90,1},
new object[]{"学生3",60,2},
new object[]{"学生4",70,2},
new object[]{"学生5",80,3},
new object[]{"学生6",80,3},
new object[]{"学生7",10,3},
new object[]{"学生8",20,4},
new object[]{"学生9",30,4},
new object[]{"学生10",40,4},
new object[]{"学生11",80,4},
};
}
}
</script>
</head>
<body>
<form id="form1" runat="server">
<ext:ResourceManager runat="server" SourceFormatting="True"></ext:ResourceManager>
<ext:GridPanel runat="server">
<Store>
<ext:Store runat="server" ID="store1">
<Model>
<ext:Model runat="server">
<Fields>
<ext:ModelField Name="name"></ext:ModelField>
<ext:ModelField Name="score"></ext:ModelField>
<ext:ModelField Name="grade"></ext:ModelField>
</Fields>
</ext:Model>
</Model>
</ext:Store>
</Store>
<ColumnModel>
<Columns>
<ext:SummaryColumn runat="server" Text="姓名" DataIndex="name" SummaryType="Count">
<SummaryRenderer Handler="return ((value === 0 || value > 1) ? '(' + value +' 人)' : '(1 人)');" />
</ext:SummaryColumn>
<ext:SummaryColumn runat="server" Groupable="False" DataIndex="score" SummaryType="Average" Text="平均成绩"></ext:SummaryColumn>
<ext:SummaryColumn runat="server" DataIndex="grade" Text="年级"></ext:SummaryColumn>
</Columns>
</ColumnModel>
<Features>
<ext:GroupingSummary
ID="GroupingSummary1"
runat="server"
GroupHeaderTplString="{grade}" />
</Features>
</ext:GridPanel>
</form>
</body>
</html>

Daniil
Sep 23, 2013, 6:45 AM
Hi @tobros,

I guess you should add this setting for the Store.

GroupField="grade"