$find(RadNumericTextBox) in Edit Form Template

2 posts, 0 answers
  1. Jay
    Jay avatar
    73 posts
    Member since:
    Dec 2011

    Posted 07 Nov 2017 Link to this post

    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.

     

  2. Marin Bratanov
    Admin
    Marin Bratanov avatar
    4837 posts

    Posted 09 Nov 2017 Link to this post

    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.
Back to Top