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

[Solved] OnClientSelectedIndexChanged issue

1 Answer 146 Views
ComboBox
This is a migrated thread and some comments may be shown as answers.
Steve White
Top achievements
Rank 1
Steve White asked on 27 Oct 2009, 05:41 PM
I have a combobox in each row of a hierarchical grid. Each combobox is wired up to the same OnClientSelectedIndexChanged event. Within the client event I'm looping all child rows and all decendents and setting the combobox value to the selected value in the parent row.

However, when I use item.select() it is actually triggering the OnClientSelectedIndexChanged event for each child combobox.

How can I prevent this from happening and still keep one js function to handle all eventualities?

I've tried item.set_value and item_set_text. They do seem to work, but only work once.

Do you have an example that illustrates how this can be done?

thanks,

Steve

1 Answer, 1 is accepted

Sort by
0
Veselin Vasilev
Telerik team
answered on 30 Oct 2009, 12:34 PM
Hello Steve White,

Calling the select() method of an item will always fire OnClientSelectedIndexChanged (as long as the OnClientSelectedIndexChanging is not cancelled).

Here is a workaround:

1. Define a global javascript variable which will determine whether to execute the code in the OnClientSelectedIndexChanged event:

var fireSelectedIndexChangedEvent = true;

2. Before calling the select() method set that variable to false.

fireSelectedIndexChangedEvent = false;
item.select();


3. At the beginning of the OnClientSelectedIndexChanged handler add an IF statement to check the value of the fireSelectedIndexChangedEvent variable:

function onClientSelectedIndexChangedHandler(sender, e)
{
     if (fireSelectedIndexChangedEvent)
     {
           // your code here
     }
}

Hope this helps.


Greetings,
Veselin Vasilev
the Telerik team

Instantly find answers to your questions on the new Telerik Support Portal.
Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
Tags
ComboBox
Asked by
Steve White
Top achievements
Rank 1
Answers by
Veselin Vasilev
Telerik team
Share this question
or