EnableTimeIndependentFiltering in GridTemplateColumn

4 posts, 0 answers
  1. Vasssek
    Vasssek avatar
    185 posts
    Member since:
    Aug 2010

    Posted 21 Sep 2017 Link to this post

    Hello,

    I've been struggling with issue, how to get EnableTimeIndependentFiltering property working in GridTemplateColumn.

    Let me describe the issue. We have datetime columns in our SQL database. These columns have in some rows normal dates such 21.9.2017 15:10:00 but some have the intial value 01.01.1900 00:00:00. Because I don't know how to suppress this initial value to be shown, I use GridTemplateColumn instead of GridDateTimeColumn. The problem is that this column even with property DataType="System.DateTime" didn't know EnableTimeIndependentFiltering.

    Here is my sample column declaration:

    <telerik:GridTemplateColumn DataField="TransferOrder_ChangedDate" HeaderText="Dátum vykonania" HeaderStyle-Font-Bold="true"
                                   HeaderStyle-HorizontalAlign="Center" ReadOnly="True" SortExpression="TransferOrder_ChangedDate" DataType="System.DateTime"
                                   ItemStyle-HorizontalAlign="Left" UniqueName="TransferOrder_ChangedDate" FilterControlWidth="120px" ColumnGroupName="TransferOrder"
                                   AutoPostBackOnFilter="false" CurrentFilterFunction="EqualTo" >
                                   <ItemTemplate>
                                       <asp:Label ID="lbl_TransferOrder_ChangedDate" runat="server" Text='<%# ((DataRowView)Container.DataItem)["TransferOrder_ChangedDate"].ToString() == nulldateTime.ToString() ? " ": string.Format("{0:dd.MM.yyyy HH:mm:ss}", ((DataRowView)Container.DataItem)["TransferOrder_ChangedDate"]) %>'></asp:Label>
                                   </ItemTemplate>
                               </telerik:GridTemplateColumn>

     

    The question is how can I filter data based on whole day value without need to type hours, minutes and second in GridTemplateColumn ?

    Thank you

    Best regards

    Vasssek

     

     

  2. Eyup
    Admin
    Eyup avatar
    3852 posts

    Posted 26 Sep 2017 Link to this post

    Hello Vasssek,

    You should use GridDateTimeColumn for this case. You can check the suggestion provided in the last post of this thread:
    http://www.telerik.com/forums/radgrid-filter-between-dates-time#GQ5E5XrryUqA-ymth0dAwQ

    I hope this will prove helpful.


    Regards,
    Eyup
    Progress Telerik
    Try our brand new, jQuery-free Angular 2 components built from ground-up which deliver the business app essential building blocks - a grid component, data visualization (charts) and form elements.
  3. Vasssek
    Vasssek avatar
    185 posts
    Member since:
    Aug 2010

    Posted 26 Sep 2017 in reply to Eyup Link to this post

    Hello,

    I would like to use GridDateTimeColumn because it has built in functionality to filter, but as I wrote above, I need to show empty value (like &nbsp;) instead of 01.01.1900, which comes from SQL as intial date for datetime column. Could I use some kind of formatting or ?

    Your example didn't solve this issue...

    Please help.

    Thank you

    Vasssek

  4. Eyup
    Admin
    Eyup avatar
    3852 posts

    Posted 29 Sep 2017 Link to this post

    Hello Vasssek,

    If you mean the row cells, you can achieve this using this approach:
    protected void RadGrid1_ItemDataBound(object sender, GridItemEventArgs e)
    {
        if (e.Item is GridDataItem)
        {
            GridDataItem item = e.Item as GridDataItem;
            DateTime? date = DataBinder.Eval(item.DataItem, "OrderDate") as DateTime?;
            if (date.HasValue && date.Value == new DateTime(1900, 1, 1))
            {
                item["OrderDate"].Text = "";
            }
        }
    }

    That should do the trick.

    Regards,
    Eyup
    Progress Telerik
    Try our brand new, jQuery-free Angular 2 components built from ground-up which deliver the business app essential building blocks - a grid component, data visualization (charts) and form elements.
Back to Top