This is a migrated thread and some comments may be shown as answers.

Filter Column with TimeSpan

3 Answers 197 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Daniel
Top achievements
Rank 1
Daniel asked on 03 Aug 2014, 11:46 AM
Hello,

I am working on a project with a RadGrid.

In the Grid I have a column with a Timespan, But it seems that the Grid  no support that kind of type.
Is it?

Its displays this message:
No applicable method 'ToTimeSpan' exists in type 'Convert'

See video.

I’ll be glad to get a solution.

Thank you,
Daniel.

3 Answers, 1 is accepted

Sort by
0
Viktor Tachev
Telerik team
answered on 06 Aug 2014, 02:02 PM
Hi Daniel,

The GridDateTimeColumn is using picker controls to select date and they are bound to a DateTime object. Because of this you are seeing the error when trying to filter column bound to a TimeSpan.

If you would like to have a column that displays hours you could use couple of approaches. If you would like to keep the GridDateTimeColumn you could bind it to a DateTime object and display only the time part from it.

<telerik:GridDateTimeColumn DataField="Time" HeaderText="Time" UniqueName="Time" DataFormatString="{0:hh:mm:ss}"></telerik:GridDateTimeColumn>

Note that you would need to handle the filtering manually. You could use an approach similar to the one described in this article.

Another approach you could use is to replace the column with a GridTemplateColumn or GridBoundColumn.

I hope this helps.

Regards,
Viktor Tachev
Telerik
 

Check out the Telerik Platform - the only platform that combines a rich set of UI tools with powerful cloud services to develop web, hybrid and native mobile apps.

 
0
Daniel
Top achievements
Rank 1
answered on 14 Aug 2014, 10:51 AM
Hello Victor,

Thank you for your response.

Unfortunately your answer does not satisfy the requirements of the project.
In the project all columns are dynamic (only in run-time do we know the exact columns and their types). Therefore, accessing a column by name is out of the question.

Also, there are many cases when there are several columns of DATE, beside TIME columns. Therefore, accessing by type of column is not possible.

I'd love to get a solution.

 
Thank you,
Daniel.
0
Viktor Tachev
Telerik team
answered on 18 Aug 2014, 11:53 AM
Hello Daniel,

In case the columns in the RadGrid are created dynamically you could define the properties for each column in the code-behind, when generating the columns. Please check out the following article that describes how you could create the RadGrid dynamically with different structure depending on a condition.

You could use similar approach by retrieving the data from the data source and depending on the number of fetched columns, create the appropriate RadGrid structure.



Regards,
Viktor Tachev
Telerik
 

Check out the Telerik Platform - the only platform that combines a rich set of UI tools with powerful cloud services to develop web, hybrid and native mobile apps.

 
Tags
Grid
Asked by
Daniel
Top achievements
Rank 1
Answers by
Viktor Tachev
Telerik team
Daniel
Top achievements
Rank 1
Share this question
or