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

How to access and set visibility of child controls from ClientSelectedIndexChanged event handler?

5 Answers 129 Views
ListBox
This is a migrated thread and some comments may be shown as answers.
KN425000
Top achievements
Rank 1
KN425000 asked on 18 Jul 2011, 01:48 PM
I have a RadListBox, where, inside the ItemTemplate, I have a RadComboBox, another RadComboBox, and a RadTextBox.  Based on the selected value in the first RadComboBox (captured in ClientSelectedIndexChanged), I want to show or hide the other controls.  That is, if the value in the first RadComboBox is "apple," I want to show the second RadComboBox and hide the RadTextBox.  However, if the value in the first RadComboBox is "banana," I want to hide the second RadComboBox and show the RadTextBox.

What is the normal way of doing this from this event handler?

Thanks

5 Answers, 1 is accepted

Sort by
0
KN425000
Top achievements
Rank 1
answered on 18 Jul 2011, 09:15 PM

In case what I'm asking is not obvious, I want to do the following:

function RadComboBox1_ClientSelectedIndexChanged(sender)
{
     // get reference to 2nd combobox within the ItemTemplate of this list item
     var secondComboBox = /* how do I get a reference to this?  */
     var textBox = /* how do I get a reference to this? */
       
     if (sender._text == "apple")
     {
         secondComboBox.hide();   // what's the right way to do this?
         textBox.show();
     }
     else
     {
          secondComboBox.show(); 
         textBox.hide();
 
     }
 
 
}
0
Accepted
Peter Filipov
Telerik team
answered on 20 Jul 2011, 03:44 PM
Hello Kn425000,

Please review the support ticket regarding the same issue.

I am attaching the sample project from the support ticket, that implements your scenario.

Greetings,
Peter Filipov
the Telerik team

Register for the Q2 2011 What's New Webinar Week. Mark your calendar for the week starting July 18th and book your seat for a walk through of all the exciting stuff we will ship with the new release!

0
KN425000
Top achievements
Rank 1
answered on 21 Jul 2011, 01:41 PM

In the following event handler, I'm getting "Object doesn't support this property or method" on the line fo
args.set_cancel(true)
:

function OnClientClicked(sender, args) {
 
            var index = GetItem(sender);
 
            listbox.deleteItem(listbox.getItem(index));
 
            args.set_cancel(true);
        }

Any ideas?


Edit:   It looks like args.set_cancel(true) only works in the OnClientClicking event handler, not the OnClientClicked event handler that the solution proposes.
0
KN425000
Top achievements
Rank 1
answered on 21 Jul 2011, 02:03 PM

I had to change

function pageLoad() {
 
            listbox = $find("RadListBox1");
        }


to use $find("<%=RadListBox1.ClientID %>").  Was that a typo in the proposed solution, or are there some conditions in which the proposed solution works?
0
KN425000
Top achievements
Rank 1
answered on 22 Jul 2011, 12:59 PM
After making the fixes above to the proposed solution, my form works, so I'm marking this closed.
Tags
ListBox
Asked by
KN425000
Top achievements
Rank 1
Answers by
KN425000
Top achievements
Rank 1
Peter Filipov
Telerik team
Share this question
or