View Full Version : [CLOSED] Grid Group: Show full datetime but group by month day year

Feb 04, 2015, 3:50 PM
I saw this thread Group by DateTime (http://forums.ext.net/showthread.php?50401-Group-by-DateTime), but I don't think it is exactly what I would like.

Is there a way to show the full DateTime in the column but if the column is group do it by just the date and not the time.

I have the ext:DateColumn defined as

<ext:DateColumn runat="server" Text="Date Added" Format="Y-MM-dd hh:mm:ss a" Width="170" DataIndex="DateOrdered" />

Also when the grid is displayed I am grouping on a different column by default, PageNm.

<ext:Store runat="server" GroupField="PageNm" >

Feb 04, 2015, 3:54 PM
Hi Chris,

The thread that you mentioned appears to be the same request as yours. I would recommend to try it.

Feb 04, 2015, 4:08 PM
I did and I received the following results.

<ext:DataSorter Property="DateOrdered">
<Transform Handler="return Ext.Date.clearTime(item);" />

So the code above did remove the time portion of the field DateOrdered, but the column now also displays the field without time "2015-02-04 00:00:00". I would still like to see the full DateTime in the column.

Also what is the best way to format the group Tpl header?

My default definition was:

GroupHeaderTplString="Page: {name} [{rows.length} Item{[values.rows.length > 1 ? 's' : '']}]"

but when I select a different column to group by the Tpl doesn't make sense. For DateOrdered I would want it to show:

GroupHeaderTplString="Date: {name} [{rows.length} Item{[values.rows.length > 1 ? 's' : '']}]"

The {name} should be formatted to only show the date portion of the field and not "Wed Feb 04 2015 00:00:00 GMT-0500 (Eastern Standard Time)".

Feb 04, 2015, 4:26 PM
Thread 2.1 Column .GroupRenderer (http://forums.ext.net/showthread.php?20813-CLOSED-2-1-Column-GroupRenderer&highlight=Grouper) helped show how to define various GroupHeader strings based on the field being grouped.

But I am still trying to have the field DateOrdered shown in the column as a full DateTime, but group only on the date portion of the field.

Feb 05, 2015, 3:10 PM
So the code above did remove the time portion of the field DateOrdered, but the column now also displays the field without time "2015-02-04 00:00:00". I would still like to see the full DateTime in the column.

I found out that the clearTime method has the clone parameter that is false by default.

Though, I tried

<Transform Handler="return Ext.Date.clearTime(item, true);" />
but it still doesn't work. It still groups according the time part as well.

I am investigating.

Feb 05, 2015, 5:21 PM
Here is an example with some questions:

I would like to be able to select the Date Created column to group on. It should group by Month and Year and not the full date time, but I still want the Date Created column to show the full date. (YOU ARE WORKING ON THIS, previous post)
Is it OK to have hyperlinks in the group tpl string? It appears that it is, except that seperator1 below " &raquo; " causes the group not to be able to expand after collapsing just a single group. If I use seperator2 " | " every thing works fine.
Does it make sense for the Show In Groups checkbox in the column dropdown to be disabled after unchecking it and coming off the dropdown, then looking at the dropdown again. You are able to uncheck and check the box as long as the dropdown doesn't disappear. I assume in the background it knows the last grouped column because when you uncheck it the column is not added back to the grid.

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

<%@ Register Assembly="Ext.Net" Namespace="Ext.Net" TagPrefix="ext" %>
<!DOCTYPE html>
<script runat="server">
protected void Page_Load(object sender, EventArgs e)
if (X.IsAjaxRequest)



private void BuildStore()
string seperator1 = " &raquo; ";
string seperator2 = " | ";

string premiumHelp2x = "<a href='http://forums.ext.net/forum.php' Target='_blank'>Ext.Net Forums</a>" + seperator1 +
"<a href='http://forums.ext.net/forumdisplay.php?13'>Premium</a>" + seperator1 +
"<a href='http://forums.ext.net/forumdisplay.php?17-2'>2.x Premium Help</a>";

List<object> data = new List<object>
new { Id = 53271, DateCreated = DateTime.Parse("2/5/2015 11:50"), Forum = premiumHelp2x, UrlTitle ="<a href='http://forums.ext.net/showthread.php?53271'>Grid Group: Show full datetime but group by month day year</a>", User="cwolcott", Status="Open"},
new { Id = 40901, DateCreated = DateTime.Parse("8/5/2014 14:20"), Forum = premiumHelp2x, UrlTitle="<a href='http://forums.ext.net/showthread.php?40901'>[CLOSED] Field focus problem</a>", User="matrixwebtech", Status="Closed" },

this.GridStore.DataSource = data;
<head runat="server">
<title>Grid Grouping Example</title>
<ext:ResourceManager runat="server" />
<ext:GridPanel ID="GridPanel" runat="server" ClientIDMode="Static" >
<ext:Store ID="GridStore" runat="server" GroupField="Forum">
<ext:Model runat="server" IDProperty="Id">
<ext:ModelField Name="Id" />
<ext:ModelField Name="DateCreated" Type="Date" />
<ext:ModelField Name="Forum" Type="String" />
<ext:ModelField Name="UrlTitle" Type="String" />
<ext:ModelField Name="User" Type="String" />
<ext:ModelField Name="Status" Type="String" />
<GroupChange Handler="var isGrouped = this.isGrouped(); #{CartEcBtn}.setDisabled(!isGrouped);" />
<ColumnModel runat="server">
<ext:Column runat="server" Text="Id" DataIndex="Id" Width="50" Groupable="false" />
<ext:DateColumn runat="server" Text="Created" DataIndex="DateCreated" Format="Y-MM-dd hh:mm:ss a"
Width="170" />
<ext:Column runat="server" Text="User" DataIndex="User" Width="90" />
<ext:Column runat="server" Text="Status" DataIndex="Status" Width="60" />
<ext:Column runat="server" Text="Forum" DataIndex="Forum" Flex="1" />
<ext:Column runat="server" Text="Thread Title" DataIndex="UrlTitle" Flex="2" Groupable="false" />
<ext:CheckboxSelectionModel runat="server" Mode="Multi" />
<ext:Grouping ID="GridGrouping" runat="server" StartCollapsed="false" HideGroupedHeader="true">
<GroupHeaderTpl runat="server">
<tpl if="groupField === 'DateCreated'">
{name} [{rows.length} Item{[values.rows.length > 1 ? 's' : '']}]
<tpl if="groupField === 'Forum'">
Forum: {name} [{rows.length} Item{[values.rows.length > 1 ? 's' : '']}]
<tpl if="groupField === 'User'">
Creator: {name} [{rows.length} Item{[values.rows.length > 1 ? 's' : '']}]
<tpl if="groupField === 'Title'">
Month Created: {name} [{rows.length} Item{[values.rows.length > 1 ? 's' : '']}]
<tpl if="groupField === 'Status'">
Status: {name} [{rows.length} Item{[values.rows.length > 1 ? 's' : '']}]
<AfterRender Handler="#{GridGrouping}.expanded = true;" />
<ext:Toolbar runat="server">
<ext:Button ID="CartEcBtn" runat="server" Text="Expand/Collapse Groups" Icon="TableSort">
<Click Handler="#{GridGrouping} [ #{GridGrouping}.expanded ? 'collapseAll' : 'expandAll'](); #{GridGrouping}.expanded = !#{GridGrouping}.expanded;" />

Feb 06, 2015, 12:32 PM
1. Answered in the original thread.

2-3. Please start a new forum thread for, probably, each question. Having a few issues discussed in one threads complicates things a bit to maintain a thread.

Feb 06, 2015, 1:29 PM
Go ahead an close the thread.

I have submitted two additional threads for the last two questions:

(53471) Grid Group Header Tpl (http://forums.ext.net/showthread.php?53471-Grid-Group-Header-Tpl)
(53481) Grid Group dropdown "Show In Groups" implementation (http://forums.ext.net/showthread.php?53481-Grid-Group-dropdown-quot-Show-In-Groups-quot-implementation)