RadDatePicker in Grid EditFormSettings - how to get selected date ?

4 posts, 0 answers
  1. Krzysztof
    Krzysztof avatar
    29 posts
    Member since:
    Aug 2008

    Posted 12 Dec 2008 Link to this post

    Hi
    I have :
    <telerik:RadGrid ID="GridAdvert" runat="server" >    
             <MasterTableView DataKeyNames="id" >                           
               <EditFormSettings EditFormType="Template"  >    
                <EditColumn UniqueName="EditCommandColumn1">      
                </EditColumn>           
                 <FormTemplate>    
                      <telerik:RadDatePicker runat="server" ID="PickerTimeFrom"   
                        SelectedDate='<%# DataBinder.Eval( Container, "DataItem.timeFrom" ) %>' >          
                                      
                      </telerik:RadDatePicker> 
                        
                 <asp:Button ID="UpdateButton" OnClientClick="Save(this, event);" Text="Save"      
                        runat="server" />    
                </FormTemplate>                                                     
               </EditFormSettings>                       
              </MasterTableView>    
             </telerik:RadGrid>    
     

    in JavaScript block :

    function GetGridServerElement(serverID, tagName)  
                {  
                    if (!tagName)  
                        tagName = "*"; //* means all elements  
                          
                    var grid = $get("GridAdvert");  
                    var elements = grid.getElementsByTagName(tagName);  
                    for (var i = 0; i < elements.length; i++)  
                    {  
                        var element = elements[i];  
                        if (element.id.indexOf(serverID) >= 0)  
                            return element;  
                    }  
                }  
     
    function Save(sender, e)  
    {  
     
      var xx = GetGridServerElement("PickerTimeFrom","");  
        
      var firstDatePicker = $find(xx.id); <<<<<<<<<<< Problem !!!!!
      var dateToNavigate = firstDatePicker.get_selectedDate();  
     
     


    I have a problem with $find("PickerTimeFrom"). After this I get null.
    I would like to call firstDatePicker
    .get_selectedDate() for selected date. I do not know why ?

    Regards
    Krzysztof

  2. Daniel
    Admin
    Daniel avatar
    4943 posts

    Posted 15 Dec 2008 Link to this post

    Hello Krzysztof,

    Please take a look at the following code-snippet:
    <FormTemplate> 
        <telerik:RadDatePicker runat="server" ID="PickerTimeFrom" SelectedDate='<%# Eval("OrderDate") %>'
        </telerik:RadDatePicker> 
        <asp:Button ID="UpdateButton" OnClientClick="Save(this, event);" Text="Save" runat="server" /> 
    </FormTemplate> 

    <script type="text/javascript" language="javascript"
        function Save(sender, args) 
        { 
            var datePicker = $telerik.findControl(sender.parentNode, "PickerTimeFrom"); 
        } 
    </script> 

    Let me know if you need further assistance.

    Regards,
    Daniel
    the Telerik team

    Check out Telerik Trainer, the state of the art learning tool for Telerik products.
  3. UI for ASP.NET Ajax is Ready for VS 2017
  4. Krzysztof
    Krzysztof avatar
    29 posts
    Member since:
    Aug 2008

    Posted 15 Dec 2008 Link to this post

    Hi

    O still get null after :
    var datePicker = $telerik.findControl(sender.parentNode, "PickerTimeFrom"); 

    Regards
    Krzysztof
  5. Daniel
    Admin
    Daniel avatar
    4943 posts

    Posted 15 Dec 2008 Link to this post

    Hello Krzysztof,

    Please examine the attached example and let me know whether it helps.

    Note that in order to find a control with the findControl method you need to supply a parent element.

    findControl(parent_html_element, controlID);

    I hope this helps.

    Best regards,
    Daniel
    the Telerik team

    Check out Telerik Trainer, the state of the art learning tool for Telerik products.
Back to Top