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

Javascript in FormView/NestedViewTemplate

1 Answer 182 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Joachim
Top achievements
Rank 1
Joachim asked on 29 Apr 2009, 09:04 AM
Hello Telerik-Team,

I am new to using your controls and ran into the following problem:

I am using a RadGrid with a NestedViewTemplate, into which I put a Formview to display details for each grid entry.
The FormView contains several controls, checkboxes, dropdowns, textboxes, and  I need to check several dependencies between those controls using Javascript.

How can I easily gain access to the controls in each FormView in this scenario? Do I need a special findControl-method?

Hope you can help me, I am quite a bit confused atm.

1 Answer, 1 is accepted

Sort by
0
Todd Anglin
Top achievements
Rank 2
answered on 04 May 2009, 06:23 PM
Joachim-

Are you trying to access the controls in the FormView client-side with JavaScript? I'm assuming that's the case.

There are a number of approaches you could take to access these controls via JavaScript after the page loads. It all depends on how you're doing your validation. One approach is to use jQuery's adavnced DOM search support to find the controls you need and then perform your validation from there. For example, using jQuery, I could look for a specific input control in my FormView like this when my textbox blur event fires:

<asp:TextBox runat="server" onblur="handleTextBlur(this);" ... 
 
function handleTextBlur(element) 
   var control = $(element).siblings("input[id*='div-comment-']"); 

Using the "siblings" selector will limit my search to elements in the same container as my original element, and then using the "[id*= ]" syntax enables me to do a wildcard search for a control ID. Some combination of the jQuery search patterns should give you the control you need.

Hope that helps!
-Todd
Tags
Grid
Asked by
Joachim
Top achievements
Rank 1
Answers by
Todd Anglin
Top achievements
Rank 2
Share this question
or