How to compare two dates in RadGrid GridBoundColumn

2 posts, 0 answers
  1. George
    George avatar
    1 posts
    Member since:
    May 2017

    Posted 17 May 2017 Link to this post

    Hello there,

    I have a requirement to validate that an expiration date is later than a hire date. Both dates are populated in a GridBoundColumn in a RadGrid. Bellow is the code for the two columns in my aspx page:

    <telerik:GridBoundColumn ColumnEditorID="DateEditor" DataField="Hired" Visible="true" ReadOnly="false" HeaderText="Hired" UniqueName="gcHired" DataType="System.String" FilterControlAltText="Filter gcHired column"></telerik:GridBoundColumn>
                                                    <telerik:GridDateTimeColumn ColumnEditorID="DateEditor" MinDate="2017-01-01" MaxDate="2030-12-31" DataFormatString="{0:MM/dd/yyyy}" DataField="Expires" HeaderText="Expires" UniqueName="gcExpires" FilterControlAltText="Filter column column" AllowFiltering="False" AllowSorting="False" DataType="System.DateTime" ReadOnly="false">
                                                        <HeaderStyle Width="100px"></HeaderStyle>
                                                    </telerik:GridDateTimeColumn>

     

    I am wondering if there is a straight forward way to achieve this. Thanks in advance!

  2. Marin Bratanov
    Admin
    Marin Bratanov avatar
    5539 posts

    Posted 19 May 2017 Link to this post

    Hello,

    I have just answered your support ticket with the same question which indicated the grid is in Batch edit mode.

    I am pasting my answer here for others with a similar question.

    I suggest you review the following articles. The first shows one way to access columns by their unique name so you can traverse the DOM and get the control objects (see the second example). The second shows the general ways to access a control object from the DOM. The third shows how you can add a custom validator that can traverse the DOM and prevent cells from closing if there are issues, so you can combine this all in a better user experience.

     

     

    Regards,

     

    Marin Bratanov
    Telerik by Progress
    Try our brand new, jQuery-free Angular 2 components built from ground-up which deliver the business app essential building blocks - a grid component, data visualization (charts) and form elements.
Back to Top