Filter Column with TimeSpan

4 posts, 0 answers
  1. Daniel
    Daniel avatar
    159 posts
    Member since:
    Feb 2014

    Posted 03 Aug 2014 Link to this post

    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.
  2. Viktor Tachev
    Admin
    Viktor Tachev avatar
    1784 posts

    Posted 06 Aug 2014 Link to this post

    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.

     
  3. Daniel
    Daniel avatar
    159 posts
    Member since:
    Feb 2014

    Posted 14 Aug 2014 in reply to Viktor Tachev Link to this post

    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.
  4. Viktor Tachev
    Admin
    Viktor Tachev avatar
    1784 posts

    Posted 18 Aug 2014 Link to this post

    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.

     
Back to Top