Using the Telerik findControl client side method

We recently ran into an issue where we needed to get a reference to a telerik control on the client side but that control was going to be inside a grid or repeater so that there would be many copies all with unique generated IDs. It

looked like maybe the function $telerik.findControl could work for us, but there was limited documentation and I couldn’t find a single example online of someone successfully using it. Pretty much every post I cam across had the person being routed to some other more convoluted work around rather than addressing why their findControl call wasn’t working. So after getting it working I figured I’d give a quick explaination.

The method is:

var telerikControl = $telerik.findControl( domElementOfSomeParent , controlIdFromServerSide );

So just to be very clear, domElementOfSomeParent is an HTML DOM object that you can get from javascript or jquery or whatever.  It defines the scope for the search for the control.  Only elements that are ancestor (children, grand children etc) of domElementOfSomeParent will be considered.  And controlIdFromServerSide is a string that is the same as the ID you are specifying on the server, even if that ID is for a control that is going to be rendered multiple times because it’s in some gridview or repeater.

What you’ll get back is the telerik client object for your control.

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s