How to manage radDataFilter filter for datetime

1 Answer 29 Views
DataFilter DateTimePicker GridView
Giovanni
Top achievements
Rank 1
Iron
Iron
Iron
Giovanni asked on 22 Nov 2023, 04:12 PM

Hi, I'm using a RadDataFilter to filter data on a RaGridView.

For datetime columns I've noticed some problems.

First, in the control the date is displayed in english format (see first attached image). When I try to change the value a datetimepicker appears and in this case the date is in italian format (according to my pc settings).

Second, I've noticed when the radDataFilter.Expression is generated the date is in english format, including time, and it is inside a couple of #, i.e the expression generated is like:

[myDate] >= #11/20/2023 14:55:07# 

I would like to have only the date without time, is it possible?
And  how can manage this expression to generate the SQL expression, cause the # is not accepted.

 

Thank you in advance for any help.

1 Answer, 1 is accepted

Sort by
0
Accepted
Nadya | Tech Support Engineer
Telerik team
answered on 23 Nov 2023, 10:37 AM

Hello, Giovanni,

Thank you for the provided pictures.

If you want to customize the text while the detetimepicker is not in edit mode, you can use the DataFilter.NodeFormatting event and change the text of the value element according to your needs. Additional information how to handle this event is available here: Formatting Nodes - RadDataFilter - Telerik UI for WinForms

Please refer to the following code snippet which sets new format to the value element:

private void DataFilter_NodeFormatting(object sender, TreeNodeFormattingEventArgs e)
{

    DataFilterCriteriaElement criteriaNode = e.NodeElement as DataFilterCriteriaElement;
    if (criteriaNode != null)
    {
        DataFilterCriteriaNode node = criteriaNode.Data as DataFilterCriteriaNode;
        criteriaNode.ValueElement.Text = ((DateTime?)node.DescriptorValue).Value.ToString("dd/MM/yyyy");
    }
}

As to your second and third questions, they have already been answered in the other thread that you have opened. Please see my reply there. 

Offtopic, we kindly ask you to use just one thread for a specific problem to contact us. Posting the same questions numerous times slows down our response time because we will need to review and address two or more tickets instead of one. 

I hope this helps. Should you have any other questions do not hesitate to contact us.

Regards,
Nadya | Tech Support Engineer
Progress Telerik

Love the Telerik and Kendo UI products and believe more people should try them? Invite a fellow developer to become a Progress customer and each of you can get a $50 Amazon gift voucher.

Giovanni
Top achievements
Rank 1
Iron
Iron
Iron
commented on 27 Nov 2023, 07:38 AM

Thank you very much, and I apologize for this second ticket.

 

Tags
DataFilter DateTimePicker GridView
Asked by
Giovanni
Top achievements
Rank 1
Iron
Iron
Iron
Answers by
Nadya | Tech Support Engineer
Telerik team
Share this question
or