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

Grid filters on TimeSpan type

0 Answers 109 Views
This is a migrated thread and some comments may be shown as answers.
Top achievements
Rank 1
Adi asked on 20 Jul 2017, 09:05 PM


i have a column in rad data grid which bind to property from TimeSpan type the kind of this column is template and i present the data in this format  HH:MM:SS, when hour present the total hours (more then 24) from this function:

protected string PrintTimeSpan(TimeSpan? time)
            return time == null ? "N/A" : string.Format("{0}:{1}:{2}", (int) time.Value.TotalHours, time.Value.Minutes, time.Value.Seconds);


I want to enable to filter this column when user input will be in same format currently when i enter input with more than 24 hours it throw error about the format, how i costume the action of some filters on template column (like "greater than" and "less than"), without to implement the section of filter template in myself.

in addition how i define validator on filter filed  to unable to enter string with wrong format, currently i can enter in this column filter of kind time span regular string and get error on page when try to filter

this is example of my column definition

01.<telerik:GridTemplateColumn DataField="AllGood" FilterControlAltText="Filter AllGood column" SortExpression="AllGood" UniqueName="AllGood" FilterControlWidth="70px">
02.                                <HeaderTemplate>
03.                                    <table style="width: 100%; text-align: center">
04.                                        <tr style="text-align: center">
05.                                            <td>
06.                                                <asp:Image runat="server" AlternateText="Status - All Good" ToolTip="Status - All Good" ImageAlign="Middle" Height="60px" Width="60px" ImageUrl='~/Images/Stations/Green.png' />
07.                                            </td>
08.                                        </tr>
09.                                    </table>
10.                                </HeaderTemplate>
11.                                <ItemTemplate>
12.                                    <asp:Label ID="AllGoodLabel" runat="server" Text='<%# PrintTimeSpan((TimeSpan?)Eval("AllGood")) %>'></asp:Label>
13.                                </ItemTemplate>
14.                            </telerik:GridTemplateColumn>



No answers yet. Maybe you can help?

Asked by
Top achievements
Rank 1
Share this question