radgrid with datepickercontrol

3 posts, 0 answers
  1. Rathan
    Rathan avatar
    20 posts
    Member since:
    Oct 2011

    Posted 30 Mar 2012 Link to this post


    This is Rathan,

    I placed the two datepickker controls inside radgrid ,i want to calculate the days between two dates using javascript.

    please help me how can i get the value of datepicker control value when i selected the date from picker  for caluclating days.

    forexample :
    var date=document.getelementbyid('datepicker1').value; (for normal javascript)

    how can i get the value of datepicker like above example.

  2. Princy
    Princy avatar
    17421 posts
    Member since:
    Mar 2007

    Posted 30 Mar 2012 Link to this post

    HI Rathan,

    Please take a look into the following code snippet I tried to find the difference between two date in the RadDatePickers.

    <telerik:RadGrid ID="RadGrid1" runat="server" >
              <telerik:RadDatePicker ID="RadDatePicker1" runat="server"></telerik:RadDatePicker>
              <telerik:RadDatePicker ID="RadDatePicker2" runat="server"></telerik:RadDatePicker>
    <asp:Button ID="Button1" runat="server" Text="diff" OnClientClick="OnClientClick(); return false;" />

    <script type="text/javascript">
        function OnClientClick()
            var grid = $find("<%=RadGrid1.ClientID%>");
            rd1 = new Date(grid.MasterTableView.get_dataItems()[0].findControl("RadDatePicker1").get_selectedDate());
            rd2 = new Date(grid.MasterTableView.get_dataItems()[0].findControl("RadDatePicker2").get_selectedDate());
            msPerDay = 24 * 60 * 60 * 1000;
            days = Math.round((rd1.valueOf() - rd2.valueOf()) / msPerDay);

    Hope this helps,

  3. Eyup
    Eyup avatar
    4076 posts

    Posted 30 Mar 2012 Link to this post

    Hello Rathan,

    I suppose this is what you are searching for:
    var date = $find('<%=RadDatePicker1.ClientID %>').get_selectedDate();
    Hope this helps.

    All the best,
    the Telerik team
    If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the RadControls for ASP.NET AJAX, subscribe to their blog feed now.
Back to Top