OnClientDropDownClosing

5 posts, 0 answers
  1. mww
    mww avatar
    257 posts
    Member since:
    Sep 2012

    Posted 22 Oct 2008 Link to this post

    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 ?
  2. Serrin
    Serrin avatar
    286 posts
    Member since:
    Sep 2008

    Posted 22 Oct 2008 Link to this post

    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.
  3. UI for ASP.NET Ajax is Ready for VS 2017
  4. mww
    mww avatar
    257 posts
    Member since:
    Sep 2012

    Posted 22 Oct 2008 Link to this post

    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
  5. Serrin
    Serrin avatar
    286 posts
    Member since:
    Sep 2008

    Posted 22 Oct 2008 Link to this post

    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? 
  6. mww
    mww avatar
    257 posts
    Member since:
    Sep 2012

    Posted 22 Oct 2008 Link to this post

    thats probably the only way im gonna be able to do it
Back to Top
UI for ASP.NET Ajax is Ready for VS 2017