How to find control ID inside the radgrid template field using java script

6 posts, 0 answers
  1. waruni
    waruni avatar
    27 posts
    Member since:
    Jan 2008

    Posted 22 Feb 2010 Link to this post


    I have rad grid control and it has template Column, i want to find the control ID(e.g rtpTime)  inside the rad grid using java script.
    As well as im using Master page.
    Can you plz tell me the way of doing this, because this is ugent.

     <telerik:GridTemplateColumn HeaderText="Time" UniqueName="time" > 
                    <telerik:RadTimePicker ID="rtpTime" runat="server" > 
                <asp:Label ID="lbltime" runat="server" Text='<%# Eval "Time","{0:t}") %>' ></asp:Label> 

  2. Shinu
    Shinu avatar
    17764 posts
    Member since:
    Mar 2007

    Posted 22 Feb 2010 Link to this post

    Hello Waruni,

    You can use the findControl() method to get reference to client object of RadControl or ASP.NET AJAX control inside the grid row.

        function getControl() { 
            var masterTable = $find("<%=RadGrid1.ClientID%>").get_masterTableView(); 
            var datePicker = masterTable.get_dataItems()[0].findControl('rtpTime');// Here 0 represents the index of crow in editmode 

  3. DevCraft R3 2016 release webinar banner
  4. waruni
    waruni avatar
    27 posts
    Member since:
    Jan 2008

    Posted 23 Feb 2010 Link to this post


    Thank you for your quick response,
     but i got following error "Object doesn't support this property or method"  why is that ?


  5. Radoslav
    Radoslav avatar
    1564 posts

    Posted 25 Feb 2010 Link to this post

    Hi Waruni,

    Could you please elaborate a bit more on your scenario? When do you want to find the RadTimePicker control with? Do you want to get it when the edit form is open or when the user clicks the Update button or on the other actions performed by the user?

    Also note that when you search for the RadTimePicker the RadGrid has to be into edit mode, otherwise the  RadTimePicker control is not rendered on the page and it can not be found on the client side.

    Additionally you could check out the following code library which illustrates how to access server controls in a grid template on the client:

    the Telerik team

    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items.
  6. Jugoslav
    Jugoslav avatar
    59 posts
    Member since:
    Mar 2011

    Posted 31 Jul 2011 Link to this post

    I have the following code which is fired on ClientFileSelected event. And it's fired but i am getting the result from the else statement all the time. Meaning i cannot find the button control to be clicked.

    function SubmitImage() {
                var masterTable = $find("<%=RadGrid1.ClientID %>").get_masterTableView();
                var mybutton = masterTable.get_dataItems()[0].findControl('SubmitImage');
               var hidden = masterTable.get_dataItems()[0].findControl('ImagePath');
               var radupload = masterTable.get_dataItems()[0].findControl('UploadImage');
                var fileInputs = radupload.getFileInputs();
                if (mybutton) {
                    hidden.value = fileInputs[0].value;
                } else {

    ASP.NET (EditItemTemplate)
        <telerik:RadButton ID="SubmitImage" runat="server" CssClass="HideUploadButtons" Text="Upload Image" OnClick="SubmitImage_Click" />
        <asp:HiddenField ID="ImagePath" runat="server" Value="" />
        <asp:Image runat="server" ID="IndicatorImage" ImageUrl="~/Images/saved.png" Visible="false" />
        <telerik:RadUpload ID="UploadImage" runat="server"
            AllowedFileExtensions=".png, .jpg, .gif"
            OverwriteExistingFiles="True" />

    Please notice that it has to be done while grid is in the edit mode
  7. Radoslav
    Radoslav avatar
    1564 posts

    Posted 04 Aug 2011 Link to this post

    Hello Jugoslav,

    The posted code executes its else clause every time because the masterTable.get_dataItems()[0].findControl('SubmitImage') code returns always null. The findControl function could be used only for GridDataItems and not for the GridEditFormItems. In your case you can find out the edited row index by using the following client side code;
    var editIndex= $find("<%=RadGrid1.ClientID %>")._editIndexes;
    Then you can use a global registry (an array really) that keeps control ID's or get all elements of a given tag name and try to find the one whose ID contains our server ID.
    Checkout the code library for more information : Accessing server controls in a grid template on the client

    I hope this helps.

    Best wishes,
    the Telerik team

    Browse the vast support resources we have to jump start your development with RadControls for ASP.NET AJAX. See how to integrate our AJAX controls seamlessly in SharePoint 2007/2010 visiting our common SharePoint portal.

Back to Top
DevCraft R3 2016 release webinar banner