I have a grid which use Header Context Menu. Filtering option is not working with DateTime Fields
<telerik:RadGrid RenderMode="Lightweight" ID="itinerariosGrid" runat="server" AutoGenerateColumns="False" EnableEmbeddedSkins="false" Skin="telerikbootstrap"
AllowFilteringByColumn="True" AllowSorting="True" AllowPaging="True" Culture="es-MX" FilterType="HeaderContext" EnableHeaderContextMenu="true" EnableHeaderContextFilterMenu="true"
AllowMultiRowSelection="True" AllowAutomaticUpdates="False" AllowAutomaticInserts="False" OnItemDataBound="itinerariosGrid_ItemDataBound"
OnNeedDataSource="itinerariosGrid_NeedDataSource" AllowAutomaticDeletes="false" EnableLinqExpressions="false"
OnInsertCommand="itinerariosGrid_InsertCommand" OnUpdateCommand="itinerariosGrid_UpdateCommand" OnDeleteCommand="itinerariosGrid_DeleteCommand">
5 Answers, 1 is accepted
In previous versions there was issue with Excel-like filtering used in combination with numeric or date columns:
https://feedback.telerik.com/Project/108/Feedback/Details/171656-object-reference-exception-is-thrown-when-filtertype-is-set-to-headercontext-and
Also, with auto-generated columns:
https://feedback.telerik.com/Project/108/Feedback/Details/183659-headercontext-filtertype-does-not-work-for-auto-generated-columns
Both issues are fixed and you can verify that you are using the latest release version of the controls.
Also, make sure that the FilterCheckListEnableLoadOnDemand property is set to the column definition:
http://docs.telerik.com/devtools/aspnet-ajax/controls/grid/functionality/filtering/checklist-filtering#filtertype-headercontext
I hope this will prove helpful.
Regards,
Eyup
Progress Telerik
Hi. This is the complete grid definition.
<telerik:RadGrid RenderMode="Lightweight" ID="itinerariosGrid" runat="server" AutoGenerateColumns="False" EnableEmbeddedSkins="false" Skin="telerikbootstrap"
AllowFilteringByColumn="True" AllowSorting="True" AllowPaging="True" Culture="es-MX" FilterType="HeaderContext" EnableHeaderContextMenu="true" EnableHeaderContextFilterMenu="true"
AllowMultiRowSelection="True" AllowAutomaticUpdates="False" AllowAutomaticInserts="False" OnItemDataBound="itinerariosGrid_ItemDataBound"
OnNeedDataSource="itinerariosGrid_NeedDataSource" AllowAutomaticDeletes="false"
OnInsertCommand="itinerariosGrid_InsertCommand" OnUpdateCommand="itinerariosGrid_UpdateCommand" OnDeleteCommand="itinerariosGrid_DeleteCommand">
<ClientSettings AllowKeyboardNavigation="true">
<Selecting AllowRowSelect="True"></Selecting>
<Scrolling AllowScroll="True" UseStaticHeaders="True" SaveScrollPosition="true"></Scrolling>
<Resizing AllowColumnResize="true" ResizeGridOnColumnResize="true" AllowResizeToFit="true" />
</ClientSettings>
<PagerStyle PageSizeControlType="RadDropDownList" Mode="NextPrevAndNumeric"></PagerStyle>
<FilterMenu RenderMode="Lightweight"></FilterMenu>
<MasterTableView AutoGenerateColumns="False" InsertItemPageIndexAction="ShowItemOnCurrentPage" EditMode="InPlace"
CommandItemDisplay="Top" ShowHeadersWhenNoRecords="true" DataKeyNames="Clave_Tiptrns,CveTransportista,Id_Trans,Viaje">
<CommandItemSettings ShowExportToExcelButton="false" ShowAddNewRecordButton="true" />
<Columns>
<telerik:GridButtonColumn ConfirmText="¿Desea Borrar este registro?" ConfirmDialogType="RadWindow"
ConfirmTitle="Borrar" HeaderText="Borrar" HeaderStyle-Width="90px" Exportable="false"
CommandName="Delete" Text="Borrar" UniqueName="DeleteColumn">
<HeaderStyle Width="90px"></HeaderStyle>
<ItemStyle CssClass="ButtonColumn" />
</telerik:GridButtonColumn>
<telerik:GridEditCommandColumn UniqueName="EditCommandColumn" Exportable="false"
HeaderText="Editar" HeaderStyle-Width="90px" UpdateText="Update">
</telerik:GridEditCommandColumn>
<telerik:GridTemplateColumn UniqueName="Clave_Tiptrns" HeaderText="Tipo Transporte" SortExpression="Clave_Tiptrns" HeaderStyle-Width="180px" FilterControlWidth="100%">
<ItemTemplate>
<%#DataBinder.Eval(Container.DataItem, "Clave_Tiptrns")%>
</ItemTemplate>
<EditItemTemplate>
<telerik:RadComboBox RenderMode="Lightweight" runat="server" ID="RComboTipo" EnableLoadOnDemand="true" OnItemsRequested="RComboTipo_ItemsRequested"
DataValueField="Clave" DataTextField="Clave" AutoPostBack="true" DropDownWidth="350px" OnSelectedIndexChanged="RComboTipo_SelectedIndexChanged"
EnableEmbeddedSkins="false" Skin="telerikbootstrap">
<DefaultItem Text="" Value="-1" />
<HeaderTemplate>
<div class="row table table-striped table-hover center-table">
<div class="col-md-4">
Clave
</div>
<div class="col-md-8">
Descripción
</div>
</div>
</HeaderTemplate>
<ItemTemplate>
<div class="row tablessa">
<div class="col-md-4">
<%# DataBinder.Eval(Container.DataItem, "Clave")%>
</div>
<div class="col-md-8">
<%# DataBinder.Eval(Container.DataItem, "Descripcion").ToString().Trim()%>
</div>
</div>
</ItemTemplate>
</telerik:RadComboBox>
</EditItemTemplate>
</telerik:GridTemplateColumn>
<telerik:GridTemplateColumn UniqueName="CveTransportista" HeaderText="Transportista" SortExpression="CveTransportista" HeaderStyle-Width="180px" FilterControlWidth="100%">
<ItemTemplate>
<%#DataBinder.Eval(Container.DataItem, "CveTransportista")%>
</ItemTemplate>
<EditItemTemplate>
<telerik:RadComboBox RenderMode="Lightweight" runat="server" ID="RComboTransportista" EnableLoadOnDemand="true" OnItemsRequested="RComboTransportista_ItemsRequested"
DataValueField="Clave" DataTextField="Clave" AutoPostBack="true" DropDownWidth="350px" OnSelectedIndexChanged="RComboTransportista_SelectedIndexChanged"
EnableEmbeddedSkins="false" Skin="telerikbootstrap" HighlightTemplatedItems="true">
<DefaultItem Text="" Value="-1" />
<HeaderTemplate>
<div class="row table table-striped table-hover center-table">
<div class="col-md-4">
Clave
</div>
<div class="col-md-8">
Descripción
</div>
</div>
</HeaderTemplate>
<ItemTemplate>
<div class="row tablessa">
<div class="col-md-4">
<%# DataBinder.Eval(Container.DataItem, "Clave")%>
</div>
<div class="col-md-8">
<%# DataBinder.Eval(Container.DataItem, "Descripcion").ToString().Trim()%>
</div>
</div>
</ItemTemplate>
</telerik:RadComboBox>
</EditItemTemplate>
</telerik:GridTemplateColumn>
<telerik:GridTemplateColumn UniqueName="Id_Trans" HeaderText="Id Transporte" SortExpression="Id_Trans" HeaderStyle-Width="180px" FilterControlWidth="100%">
<ItemTemplate>
<%#DataBinder.Eval(Container.DataItem, "Id_Trans")%>
</ItemTemplate>
<EditItemTemplate>
<telerik:RadTextBox CssClass="form-control" runat="server" ID="txtIdTransp" EnableEmbeddedSkins="false" Skin="telerikbootstrap"
OnTextChanged="txtIdTransp_TextChanged" AutoPostBack="true"></telerik:RadTextBox>
</EditItemTemplate>
</telerik:GridTemplateColumn>
<telerik:GridBoundColumn DataField="Viaje" HeaderText="Viaje" SortExpression="Viaje" HeaderStyle-Width="150px"
UniqueName="Viaje" MaxLength="30">
</telerik:GridBoundColumn>
<telerik:GridDateTimeColumn DataField="FechaLlegada" HeaderText="Fecha Arribo" SortExpression="FechaLlegada" HeaderStyle-Width="180px" PickerType="DateTimePicker"
UniqueName="FechaLlegada" DataFormatString="{0:dd/MM/yyyy HH:mm:ss}" DefaultInsertValue="" DataType="System.DateTime" EditDataFormatString="dd/MM/yyyy HH:mm:ss" FilterDateFormat="dd/MM/yyyy HH:mm:ss">
</telerik:GridDateTimeColumn>
<telerik:GridDateTimeColumn DataField="FechaSalida" HeaderText="Fecha Zarpe" SortExpression="FechaSalida" HeaderStyle-Width="180px" PickerType="DatePicker"
UniqueName="FechaSalida" DataFormatString="{0:dd/MM/yyyy HH:mm:ss}" DefaultInsertValue="" DataType="System.DateTime" EditDataFormatString="dd/MM/yyyy HH:mm:ss" FilterDateFormat="dd/MM/yyyy HH:mm:ss">
</telerik:GridDateTimeColumn>
<telerik:GridDateTimeColumn DataField="FechaInicio" HeaderText="Inicio Operación" SortExpression="FechaInicio" HeaderStyle-Width="180px" PickerType="DatePicker"
UniqueName="FechaInicio" DataFormatString="{0:dd/MM/yyyy HH:mm:ss}" DefaultInsertValue="" DataType="System.DateTime" EditDataFormatString="dd/MM/yyyy HH:mm:ss" FilterDateFormat="dd/MM/yyyy HH:mm:ss">
</telerik:GridDateTimeColumn>
<telerik:GridDateTimeColumn DataField="FechaFin" HeaderText="Fin Operación" SortExpression="FechaFin" HeaderStyle-Width="180px" PickerType="DatePicker"
UniqueName="FechaFin" DataFormatString="{0:dd/MM/yyyy HH:mm:ss}" DefaultInsertValue="" DataType="System.DateTime" EditDataFormatString="dd/MM/yyyy HH:mm:ss" FilterDateFormat="dd/MM/yyyy HH:mm:ss">
</telerik:GridDateTimeColumn>
<telerik:GridBoundColumn DataField="NoCtaPorte" HeaderText="Viaje API" SortExpression="NoCtaPorte" HeaderStyle-Width="150px"
UniqueName="NoCtaPorte" MaxLength="30">
</telerik:GridBoundColumn>
<telerik:GridBoundColumn DataField="Estatus" HeaderText="Estatus" SortExpression="Estatus" HeaderStyle-Width="150px"
UniqueName="Estatus" MaxLength="30">
</telerik:GridBoundColumn>
<telerik:GridBoundColumn DataField="Chofer" HeaderText="Chofer" SortExpression="Chofer" HeaderStyle-Width="150px"
UniqueName="Chofer" MaxLength="30">
</telerik:GridBoundColumn>
<telerik:GridBoundColumn DataField="NoEconomico" HeaderText="No. Economico" SortExpression="NoEconomico" HeaderStyle-Width="150px"
UniqueName="NoEconomico" MaxLength="30">
</telerik:GridBoundColumn>
<telerik:GridBoundColumn DataField="NoBuqueAduana" HeaderText="Buque Aduana" SortExpression="NoBuqueAduana" HeaderStyle-Width="150px"
UniqueName="NoBuqueAduana" MaxLength="30">
</telerik:GridBoundColumn>
<telerik:GridBoundColumn DataField="ViajeAduana" HeaderText="Viaje Aduana" SortExpression="ViajeAduana" HeaderStyle-Width="150px"
UniqueName="ViajeAduana" MaxLength="30">
</telerik:GridBoundColumn>
<telerik:GridBoundColumn DataField="BuqueAduanaExportacion" HeaderText="Buque Aduana - Expo" SortExpression="BuqueAduanaExportacion" HeaderStyle-Width="150px"
UniqueName="BuqueAduanaExportacion" MaxLength="30">
</telerik:GridBoundColumn>
<telerik:GridBoundColumn DataField="ViajeAduanaExportacion" HeaderText="Buque Aduana - Expo/Viaje" SortExpression="ViajeAduanaExportacion" HeaderStyle-Width="150px"
UniqueName="ViajeAduanaExportacion" MaxLength="30">
</telerik:GridBoundColumn>
<telerik:GridDateTimeColumn DataField="FechaFondeo" HeaderText="Fecha Fondeo" SortExpression="FechaFondeo" HeaderStyle-Width="180px" PickerType="DatePicker"
UniqueName="FechaFondeo" DataFormatString="{0:dd/MM/yyyy HH:mm:ss}" DefaultInsertValue="" DataType="System.DateTime" EditDataFormatString="dd/MM/yyyy HH:mm:ss" FilterDateFormat="dd/MM/yyyy HH:mm:ss">
</telerik:GridDateTimeColumn>
</Columns>
<PagerStyle PageSizeControlType="RadDropDownList"></PagerStyle>
</MasterTableView>
</telerik:RadGrid>
I have installed 2017.2.711 version of Telerik AJAX.
No generated Columns
I also try to add FilterCheckListEnableLoadOnDemand but the problem persit. Besides i found another error. when you set PickerType="DateTimePicker" and EditDataFormatString="dd/MM/yyyy HH:mm:ss" FilterDateFormat="dd/MM/yyyy HH:mm:ss" the filter datetime picker ignore the format and the date is set like this "06/09/2017 12:00 a. m."
You can check the attached web site sample for Excel-like filtering implementation in combination with a DateTime field.
Regards,
Eyup
Progress Telerik
You can run the sample provided in my previous post using the following steps:
1. Open Visual Studio
2. File menu
3. Open option
4. Select Web site and target the web site folder.
5. Include a Bin folder with the Telerik dll assemblies.
I am also sending another sample. If the issue remains, you can modify one of these samples to demonstrate the observed issue and open a formal support ticket to send it back to us for additional examination.
Regards,
Eyup
Progress Telerik