2 posts, 0 answers
  1. Kenneth
    Kenneth avatar
    70 posts
    Member since:
    Feb 2008

    Posted 02 Jul 2008 Link to this post

    I think I just misunderstand the clientside model but here's what I'm trying to achieve.

    I am trying to get a clientside reference to a raddatepicker in the editformtemplate of a radgrid. I've used the code previously provided in this forum to do this:

              //walks over all elements with the specified tag name inside our grid 
                //does not require registration, but is a bit more complex 
                function GetGridServerElement(serverID, tagName) 
                    if (!tagName) 
                        tagName = "*"//* means all elements 
                    var grid = $get("<%=RadGrid1.ClientID %>"); 
                    var elements = grid.getElementsByTagName(tagName); 
                    for (var i = 0; i < elements.length; i++) 
                        var element = elements[i]; 
                        if ( >= 0) 
                            return element; 

    When I call this function, it does return what looks like the correct object.

    However, when I examine the returned object it does not have the methods or properties of the raddatepicker client side object.


    var rdp = GetGridServerElement("rdpStartDate","*")

    returns a valid object and it seems to be related to what I want (one of the properties 'className' is equal to 'pickerWrapper_Telerik'), but it does not seem to be a raddatepicker object. I would have expected to be able to do something like this:


    But, it doesn't work. I think there is some relationships between the object a get back from GetGridServerElement() and the expected client object - but I can't figure it out.

    Can you please help??

  2. Veli
    Veli avatar
    2002 posts

    Posted 03 Jul 2008 Link to this post

    Hi Kenneth,

    This sample method seems it is returning the DOM object RadDatePicker, instead of the client object. Therefore, you do not have the client properties and methods in the returned object. If you need to get a reference to the client RadDatePicker object, one approach you can take is the following:

    1. In the ItemDataBound event, get the edited/inserted edit form item
    2. Find the RadDatePicker server object using the FindControl() method and assign its ClientID to a hidden input on the page
    3. In the javascript function that you use, get the value of the hidden input and use it as an argument for the document.getElementById() method to find the client RadDatePicker object.

    Here is some sample code you can start from:

    void RadGrid1_ItemDataBound(object sender, Telerik.Web.UI.GridItemEventArgs e) 
        if(e.Item is GridEditFormItem && e.Item.IsInEditMode) 
            GridEditFormItem item = (GridEditFormItem)e.Item; 
            //hiddenInput is the ID of the <input type="hidden"> element on the page 
            hiddenInput.Value =  (item.FindControl("RadDatePicker1"as RadDatePicker).ClientID 

    And in the javascript function:

    var pickerId = $get('hiddenInput').value; 
    var radDatePicker = $find(pickerId); 

    the Telerik team

    Instantly find answers to your questions at the new Telerik Support Center
  3. DevCraft R3 2016 release webinar banner
Back to Top