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

$find(RadNumericTextBox) in Edit Form Template

1 Answer 66 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Jay
Top achievements
Rank 2
Iron
Iron
Veteran
Jay asked on 07 Nov 2017, 05:49 PM

I have a RadGrid with an Edit Form Template. In the template, I have a couple RadNumericTextBoxes that I need to enable/disable depending on some checkboxes in the form.

In my javascript, when I do $find("<%= RadNumericTextBoxInGridEditFormTemplate.ClientId %>"), I get a compilation error when I visit the page that says RadNumericTextBoxInGridEditFormTemplate does not exist. This is understandable because it is not there yet.

I am working around this by doing

var indirect = $(".my-class"); // Specified using CssClass="my-class" on RadNumericTextBoxInGridEditFormTemplate
var textbox = $find(indirect.attr("id"));

which works. I am just wondering if there's a better/more approved way to do this.

 

1 Answer, 1 is accepted

Sort by
0
Marin Bratanov
Telerik team
answered on 09 Nov 2017, 03:53 PM

Hi Jay,

This is the general approach you need to take. This is so because:

  • this is not rendered at all times
  • this is in a template so IDs of the controls inside change and to get a reference on the server you must traverse the control hierarchy (which may be more difficult than the DOM traversal thanks to jQuery)


Regards,

Marin Bratanov
Progress Telerik
Try our brand new, jQuery-free Angular components built from ground-up which deliver the business app essential building blocks - a grid component, data visualization (charts) and form elements.
Tags
Grid
Asked by
Jay
Top achievements
Rank 2
Iron
Iron
Veteran
Answers by
Marin Bratanov
Telerik team
Share this question
or