Grid Expression Editor Question

1 Answer 27 Views
GridView
Brian
Top achievements
Rank 1
Brian asked on 16 Aug 2024, 09:18 PM

Using the expression editor in a gridview, I'm trying to determine how much time in minutes has passed between a column that only has time and NOW()

 

Column:  arrived_time (time)

something along the line of: DATEDIFFMINUTE(arrived_time, NOW()) >= 15

since arrived_time is time only, it seems to fail when compared to NOW().

Is there a way to add today()+arrived_time to get a proper datetime value?  

End goal is if more than 15 minutes has passed since arrived_time then change RowBackColor

1 Answer, 1 is accepted

Sort by
0
Dinko | Tech Support Engineer
Telerik team
answered on 21 Aug 2024, 12:59 PM

Hi Brian,

Thank you for your interest in our RadGridView control for WinForms.

I am assuming that method NOW() returns the DateTime object. Also by time you mean TimeSpan. Correct me if I am wrong. In general, the DateTime.Now expose the TimeOfDay property which is of type TimeSpan. Then you can try to compare them. 

If I am in the wrong direction, can you confirm that your project is targeting WinForms, also can you share the type of the date-time objects used in your application? Any other additional information will be highly appreciated.

Regards,
Dinko | 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.

Brian
Top achievements
Rank 1
commented on 21 Aug 2024, 01:24 PM

I  believe NOW() returns DateTime, yes.

Our column contains the Time portion of a DateTimeOffset field vs a TimeSpan

 

I am actually trying to use a Time value and DateTime value to obtain the Timespan result.

Targeting WinForms, yes.

Underlying DB field is TimeDateOffset, the grid is displaying a dynamic column displaying only the Time aspect of that db column.

 

So:
DBField DateTimeOffset

Dynamic column displays Time of that db field

Desire is:   Time value - Now to get TimeSpan to do a conditional format based on the number of minutes passed.

I suspect I'll need to do something like (Add current date to Time column) - NOW() = Timespan.

The biggest challenge is that I cannot seem to find any help/guide/definition on the Expression Editor in the telerik controls for runtime use, there is plenty for developers, but not much for runtime users.

Thanks for your response.

Dinko | Tech Support Engineer
Telerik team
commented on 26 Aug 2024, 10:07 AM

I appreciate the additional information. The control does not provide such a filter UI for the end user. Currently, the user can choose a DateTime value to filter a DateTime column using the following options:

The end user will need to manually type the current date time (Now()) to filter the column. Filtering the column by passed time is not included in the default options. For such requirements, we have added an option to apply a custom filter to the control. You can check the Custom Filtering help article. In a few words, you can enable the custom filter behavior and subscribe to the CustomFiltering event. In the event handler, depending on your logic, you can specify if a row is visible or not. Please, go thought the article to get familiar with this functionality.

Now for the end user, you will need to add additional UI elements. You can check the Customizing composite filter dialog help article for this. You can customize one of the two filter dialogs mentioned in the article per your requirements.

I hope that the provided information above will help you get started.

 

 

Brian
Top achievements
Rank 1
commented on 26 Aug 2024, 01:06 PM | edited

Thanks for your response, this is actually a conditional format control as opposed to a column filter.

What I'm hoping to find is a help file or guide for the expression editor on what all the different functions/operators/Constants are and how they function.

 

 

 

Dinko | Tech Support Engineer
Telerik team
commented on 28 Aug 2024, 11:05 AM

Thank you for specifying that you are using the ExpressionEditor. I missed the fact that the code syntax could be from the RadExpressionEditor. The description at the bottom part of the control gives you additional information for the clicked function.

The DATEDIFFMINUTE() expects DateTime values as a parameter. That is why it will not work with TimeSpan values. However, you can create and add custom expressions. You can check the Customizing RadExpressionEditor help article for this. This way you can handle the input in code. I hope that by following the steps in the article, you will implement your requirements.

Tags
GridView
Asked by
Brian
Top achievements
Rank 1
Answers by
Dinko | Tech Support Engineer
Telerik team
Share this question
or