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

RadDatePicker in Grid EditFormSettings - how to get selected date ?

3 Answers 133 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Krzysztof
Top achievements
Rank 1
Krzysztof asked on 12 Dec 2008, 06:03 PM
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

3 Answers, 1 is accepted

Sort by
0
Daniel
Telerik team
answered on 15 Dec 2008, 11:25 AM
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.
0
Krzysztof
Top achievements
Rank 1
answered on 15 Dec 2008, 11:58 AM
Hi

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

Regards
Krzysztof
0
Daniel
Telerik team
answered on 15 Dec 2008, 05:28 PM
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.
Tags
Grid
Asked by
Krzysztof
Top achievements
Rank 1
Answers by
Daniel
Telerik team
Krzysztof
Top achievements
Rank 1
Share this question
or