PDA

View Full Version : [CLOSED] Change Grouped Title to something arbitrary, client side



rthiney
Feb 05, 2014, 6:53 PM
I have a grid that is grouped by a specific field.
Depending on unrelated data that is in the store, I want to change the title of the groups.
How can I do that on the client-side?

Daniil
Feb 06, 2014, 3:44 AM
Hi @rthiney,

You could change the getTpl function (entirely or just something inside) and refresh the GridPanel.

Example

<%@ 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)
{
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" }
};
}
}
</script>

<!DOCTYPE html>

<html>
<head runat="server">
<title>Ext.NET v2 Example</title>

<script>
var getTpl = function (values) {
return values.name;
};
</script>
</head>
<body>
<form runat="server">
<ext:ResourceManager runat="server" />

<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 runat="server">
<GroupHeaderTpl runat="server">
<Html>
{[getTpl(values)]}
</Html>
</GroupHeaderTpl>
</ext:Grouping>
</Features>
</ext:GridPanel>
</form>
</body>
</html>