It's a pity that the GridTemplateColumn doesn't support standard filter editors based on either the DataType or DateField data type (e.g., a DateTime data type is rendered as though it was a GridDateTimeColumn filter editor). This seems like an easy implementation if <FilterTemplate> is not included but filtering is turned on. Or another idea would be an alternative to <FilterTemplate> that would turn on the standard filter editor and let you set attributes on that. I really want the filter button without all the extra work.
But maybe this is a quick way around it? This is the column in the grid:
And here's what I did in grid_ItemCreated:
Any reason I can't do that? It seems to filter perfectly and appears to fit in with the Telerik examples that just assume there's always TextBox in Controls[0] anyway.
Feedback?
But maybe this is a quick way around it? This is the column in the grid:
<telerik:GridTemplateColumn HeaderText="Expires On" DataType="System.DateTime" Visible="true" ShowFilterIcon="true" ShowSortIcon="true" UniqueName="dpExpDate" DataField="EXPIRATION_DATE" AllowFiltering="true" SortExpression="EXPIRATION_DATE" AllowSorting="true" FilterListOptions="VaryByDataType" > <HeaderStyle Width="240px" /> <ItemStyle Width="240px" /> <ItemTemplate> <asp:Label runat="server" ID="lblExpDate" /> </ItemTemplate> <EditItemTemplate> <telerik:RadDateTimePicker runat="server" ID="dpExpDate" Skin="Office2010Blue" Width="220px"> <DateInput Display="true" DisplayDateFormat="G" DateFormat="G" runat="server" Font-Size="13px" Font-Name="Arial" /> <TimePopupButton Visible="false" /> </telerik:RadDateTimePicker><asp:Label runat="server" ID="lblInsertIn" Text="In" /> <telerik:RadDropDownList runat="server" ID="ddlInsertHours" Font-Names="Arial" Font-Size="13px" Width="80px" Skin="Office2010Blue" /> <asp:Label runat="server" ID="lblInsertHours" Text="Hours" /> </EditItemTemplate></telerik:GridTemplateColumn>And here's what I did in grid_ItemCreated:
if (e.Item is GridFilteringItem){ GridFilteringItem item = e.Item as GridFilteringItem; if (item["dpExpDate"].Controls[0] is TextBox) { DateTime value = DateTime.MinValue; DateTime.TryParse(gridBatches.MasterTableView.GetColumn("dpExpDate").CurrentFilterValue, out value); RadDateTimePicker pick = new RadDateTimePicker(); pick.Width = Unit.Pixel(200); pick.DateInput.DateFormat = "G"; pick.DateInput.DisplayDateFormat = "G"; pick.TimePopupButton.Visible = false; pick.DateInput.Width = Unit.Pixel(180); pick.Skin = "Office2010Blue"; pick.DateInput.Font.Size = FontUnit.Parse("13px"); pick.DateInput.Font.Name = "Arial"; if (!value.Equals(DateTime.MinValue)) pick.DbSelectedDate = value; item["dpExpDate"].Controls.RemoveAt(0); item["dpExpDate"].Controls.AddAt(0, pick); }}Any reason I can't do that? It seems to filter perfectly and appears to fit in with the Telerik examples that just assume there's always TextBox in Controls[0] anyway.
Feedback?
