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

Dropdown event that reacts only to user actions?

3 Answers 166 Views
DropDownList
This is a migrated thread and some comments may be shown as answers.
IT Department
Top achievements
Rank 1
IT Department asked on 29 Jul 2014, 03:27 PM
We have been using the SelectedIndexChanged event to react to user selections in dropdowns. The problem is that this event also fires when the DataSource is set, when the user is using the arrow keys to browse through the dropdown items, and when different items are selected using AutoComplete. Quite often, changing a dropdown selection can trigger a long and expensive process of database calls and changes to other controls.

I would like to use an event that only fires when the user has truly made a selection. We have been handling this problem by either setting module-level flags to ignore the SelectedIndexChanged event, or temporarily disconnecting the event handler.

Is there a different event that will fire only for actual user interaction? The Windows Forms combo box has a SelectionChangeCommitted event that looks better for this purpose, but I don't see an equivalent event for the Telerik dropdown.

3 Answers, 1 is accepted

Sort by
0
Dimitar
Telerik team
answered on 01 Aug 2014, 11:04 AM
Hello Grant,

Thank you for writing.

In this case we cannot determine when the user has truly made a change or is just pressing the arrows numerous times. The SelectionChangeCommitted event fires only when the selected item is changed by the user, but I don't think that it can determine when the user is making a real choice or not. The case where the index is changed programmatically can be easily avoided by just using a flag or unsubscribing and then subscribing to the event. So there is no better event that can be currently used. 

If you have any other questions, please do not hesitate to contact us.

Regards,
Dimitar
Telerik
 
Check out Telerik Analytics, the service which allows developers to discover app usage patterns, analyze user data, log exceptions, solve problems and profile application performance at run time. Watch the videos and start improving your app based on facts, not hunches.
 
0
IT Department
Top achievements
Rank 1
answered on 01 Aug 2014, 02:01 PM
Are you saying that I should see a SelectionChangeCommitted event? I see no such event in the Telerik.WinControls.UI.RadDropDownList control (Q1 2014 version).

SelectionChangeCommitted, as defined in the standard Windows combo box, would be pretty close to what I need, other than firing as the user browses the list. It would certainly be a lot closer that SelectedIndexChanged, but I don't see that SelectionChangeCommitted is available.
0
Dimitar
Telerik team
answered on 05 Aug 2014, 07:49 AM
Hello Grant,

Thank you for writing back.

I was pointing the SelectionChangeCommitted in the default .NET control. To replicate the same behavior with our RadDropDownList you can use a simple flag:
bool isIndexChagedByCode;
void radDropDownList1_SelectedIndexChanged(object sender, Telerik.WinControls.UI.Data.PositionChangedEventArgs e)
{
    if (!isIndexChagedByCode)
    {
        Console.WriteLine("Index changed by user");
    }
    else
    {
        Console.WriteLine("Index changed by code");
    }
}
 
private void radButton1_Click(object sender, EventArgs e)
{
    isIndexChagedByCode = true;
    radDropDownList1.SelectedIndex = 5;
    isIndexChagedByCode = false;
}

I hope this helps. Should you have any other questions do not hesitate to ask.
 
Regards,
Dimitar
Telerik
 
Check out Telerik Analytics, the service which allows developers to discover app usage patterns, analyze user data, log exceptions, solve problems and profile application performance at run time. Watch the videos and start improving your app based on facts, not hunches.
 
Tags
DropDownList
Asked by
IT Department
Top achievements
Rank 1
Answers by
Dimitar
Telerik team
IT Department
Top achievements
Rank 1
Share this question
or