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

Yet another Grid FormTemplate client side problem

2 Answers 83 Views
Input
This is a migrated thread and some comments may be shown as answers.
Boris
Top achievements
Rank 1
Boris asked on 08 Nov 2012, 08:37 PM
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 Answers, 1 is accepted

Sort by
0
Accepted
Andrey
Telerik team
answered on 13 Nov 2012, 11:58 AM
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.
0
Boris
Top achievements
Rank 1
answered on 13 Nov 2012, 02:25 PM
Works fine.  Thanks!
Tags
Input
Asked by
Boris
Top achievements
Rank 1
Answers by
Andrey
Telerik team
Boris
Top achievements
Rank 1
Share this question
or