This is a migrated thread and some comments may be shown as answers.
EnableTimeIndependentFiltering in GridTemplateColumn
3 Answers 24 Views
This is a migrated thread and some comments may be shown as answers.
Vasssek
Top achievements
Rank 1
Vasssek asked on 21 Sep 2017, 01:21 PM

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

 

 

3 Answers, 1 is accepted

Sort by
0
Eyup
Telerik team
answered on 26 Sep 2017, 05:32 AM
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.
0
Vasssek
Top achievements
Rank 1
answered on 26 Sep 2017, 03:35 PM

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

0
Eyup
Telerik team
answered on 29 Sep 2017, 02:06 PM
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.
Tags
Grid
Asked by
Vasssek
Top achievements
Rank 1
Answers by
Eyup
Telerik team
Vasssek
Top achievements
Rank 1
Share this question
or