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

OnClientDropDownClosing

4 Answers 75 Views
ComboBox
This is a migrated thread and some comments may be shown as answers.
mww
Top achievements
Rank 1
mww asked on 22 Oct 2008, 02:45 PM
I need to determine the value selected in a combo in the OnClientDropDownClosing event.  Ive setup the combo like this

<telerik:RadComboBox ID="RadComboBoxCategories" Runat="server"  
                                    EnableLoadOnDemand="true" OnClientItemsRequested="ItemsLoaded"  
                                    OnClientItemsRequesting="OnClientItemsRequesting"  
                                    onitemsrequested="RadComboBoxCategories_ItemsRequested" Skin="Web20"  
                                    Width="250px" AutoPostBack="False" OnClientDropDownClosing="OnCategoriesClientDropDownClosing"
                                    <CollapseAnimation Duration="200" Type="OutQuint" /> 
                                </telerik:RadComboBox> 
 and have this javascript function

function OnCategoriesClientDropDownClosing(sender, eventArgs) { 
                var txt = sender.get_text(); 
                                 
                if (txt != "")  
                { 
                    var masterTableView = $find("<%= RadGridSecondaryCategories.ClientID %>").get_masterTableView(); 
                    var category = ""
                    for (var i = 0j = masterTableView.get_dataItems().length; i < j; i++) { 
                        var thecell = masterTableView.getCellByColumnUniqueName(masterTableView.get_dataItems()[0], "Category"); 
                        category = masterTableView.getCellByColumnUniqueName(masterTableView.get_dataItems()[0], "Category").innerText; 
                        
                        category = trim(category); 
                        if (txt == category)  
                        { 
                            eventArgs.set_cancel(true); 
                        } 
                        else  
                        { 
                            eventArgs.set_cancel(false); 
                        } 
                    } 
                } 
            } 

The problem is that sender.get_text() returns the original value in the dropdown, not the newly selected value.  I need this to perform a check in a grid that determines if the newly selectd value exists in the grid and if it does the operation is cancelled.

How can I get the newly selected value in the dropdown ?

4 Answers, 1 is accepted

Sort by
0
Serrin
Top achievements
Rank 1
answered on 22 Oct 2008, 05:29 PM
Hey Mark,

Check out this demo, specifically down in the code to the line:

OnClientSelectedIndexChanged="HandleEndChanging" 

This fires for the new value, as you can see by the demo that at this point it has the text of the new item, not the old one.
0
mww
Top achievements
Rank 1
answered on 22 Oct 2008, 06:01 PM
doesnt this happen after the value has been changed ?  I want to stop the event happening if the new value already exists in a grid
0
Serrin
Top achievements
Rank 1
answered on 22 Oct 2008, 07:44 PM
Hmm, this is kinda tricky, because there is OnClientSelectedIndexChanged and OnClientSelectedIndexChanging.  Changed returns value after change, changing returns value before change.  Maybe you can throw the original value into a hidden field on Changing, then when Changed fires you check grid, do your compare, and revert it to the value in the hidden field if it doesn't check out? 
0
mww
Top achievements
Rank 1
answered on 22 Oct 2008, 08:13 PM
thats probably the only way im gonna be able to do it
Tags
ComboBox
Asked by
mww
Top achievements
Rank 1
Answers by
Serrin
Top achievements
Rank 1
mww
Top achievements
Rank 1
Share this question
or