Yet another Grid FormTemplate client side problem

3 posts, 1 answers
  1. Boris
    Boris avatar
    275 posts
    Member since:
    Oct 2012

    Posted 08 Nov 2012 Link to this post

    I recently posted a problem about disabling controls client-side within a RadGrid FormTemplate: http://www.telerik.com/community/forums/aspnet-ajax/input/unable-to-find-a-usable-method-for-enabling-disabling-a-textbox-in-a-formtemplate.aspx

    That screen works.  I can now control the enabling/disabling of RadTextBoxes using a function call from a checkbox.
    Now I have a similar problem.  I have a similar screen in which the FormTemplate has several RadComboBoxes and RadButtons. 
    What I want to do is enable/disable a RadComboBox and a RadButton depending on the value of another RadComboBox.

    I've attached a function to a RadComboBox's OnClientSelectedIndexChanged event.  I know the function is being called.  I know I'm getting the correct value of the dropdown.  I know I'm getting back handles from the $telerik.findElement calls.   As far as I can tell from your documentation I'm using the correct enable/disable calls for a RadButton and RadComboBox. 

    But this time nothing works.  The status of the controls is not changing.  Here's the code.

    function test(sender, args) {
        var editForm = $find("<%=RadGrid1.ClientID%>").get_masterTableView().get_editItems()[0].get_editFormItem();
        var btn = $telerik.findElement(editForm, "btnSave");
        var combo = $telerik.findElement(editForm, "ComboBox1");                           

        var curVal = sender.get_value();

        // if the calling combo box has this value,
        // disable the other controls.                          
        if (curVal == 3) {
           btn.set_enabled(false);
           combo.disable();                             
        }
        // Otherwise, enable
        else {
           btn.set_enabled(true);        
           combo.enable();
        }
     }

  2. Answer
    Andrey
    Admin
    Andrey avatar
    836 posts

    Posted 13 Nov 2012 Link to this post

    Hello,

    My colleague Eyup have demonstrated the approach to disable ASP TextBox control which renders on the client an input of type Text. However, RadComboBox and RadButton are composite that render complex HTML on the client and could not be hidden by only setting the disable clause to one element. In order to achieve your goal you should use the findControl method to get the client-side object of the button and the combobox controls:

    function test(sender, args) {
        var editForm = $find("<%=RadGrid1.ClientID%>").get_masterTableView().get_editItems()[0].get_editFormItem();
        var btn = $telerik.findControl(editForm, "btnSave");
        var combo = $telerik.findControl(editForm, "ComboBox1");                          
     
        var curVal = sender.get_value();
     
        // if the calling combo box has this value,
        // disable the other controls.                         
        if (curVal == 3) {
           btn.set_enabled(false);
           combo.disable();                            
        }
        // Otherwise, enable
        else {
           btn.set_enabled(true);       
           combo.enable();
        }
     }


    Greetings,
    Andrey
    the Telerik team
    If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the RadControls for ASP.NET AJAX, subscribe to their blog feed now.
  3. UI for ASP.NET Ajax is Ready for VS 2017
  4. Boris
    Boris avatar
    275 posts
    Member since:
    Oct 2012

    Posted 13 Nov 2012 Link to this post

    Works fine.  Thanks!
Back to Top