SelectedIndexChanging old value

5 posts, 0 answers
  1. eakins05
    eakins05 avatar
    12 posts
    Member since:
    Jun 2007

    Posted 15 Dec 2009 Link to this post

    Is there a way to get the old value out of the ListBox on SelectedIndexChanging event?  I'm converting a ComboBox over to a ListBox and I was previously doing something very similar to this: http://www.telerik.com/help/aspnet-ajax/combo_clientsideonclientselectedindexchanging.html.  But now my sender.get_selectedItem() returns null.  On inspection, sender._selectedValue seems to hold the previous selected value.  I can easily keep track of my previously selected item on my own, but if there's a cleaner way to do it (like before), I'm all ears.

    Thanks,
    Jared
  2. eakins05
    eakins05 avatar
    12 posts
    Member since:
    Jun 2007

    Posted 15 Dec 2009 Link to this post

    Here's my current workaround:

        var ignoreCheck = false
        var changingItem; 
        function RadListBox2_ClientSelectedIndexChanging(sender, args) 
        { 
            if (ignoreCheck) 
            { 
                ignoreCheck = false
                return
            } 
            var currentItem = changingItem; //sender.get_selectedItem(); (from before) 
            changingItem = args.get_item(); 
            if (currentItem) { 
                args.set_cancel(true); 
                PageMethods.DoCheck(currentItem.get_value(), DoCheck_Success); 
            } 
        } 
     
        function DoCheck_Success(result) 
        { 
            if (!changingItem) return
             
            if (result || confirm('Do you want to continue (changes will be lost)?')) 
            { 
                ignoreCheck = true
                changingItem.select(); 
            } 
        } 
     

    Now my args.set_cancel(true) doesn't seem to be having any effect at stopping the selection change; it's posting back before my PageMethod handler has a chance to do the confirm.  Can you help out?


  3. Genady Sergeev
    Admin
    Genady Sergeev avatar
    1600 posts

    Posted 18 Dec 2009 Link to this post

    Hi eakins05,

    After some investigation it turned out that this is bug in the RadListBox. We will try to have it fixed for the next week. Until then, I suggest that you use the workaround that you have found. I have updated your telerik points for pointing us to this issue.

    Sincerely yours,
    Genady Sergeev
    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.
  4. eakins05
    eakins05 avatar
    12 posts
    Member since:
    Jun 2007

    Posted 18 Dec 2009 Link to this post

    Thanks for the reply and for looking into this.  For anybody interested in this immediately, here's my workaround for the args.set_cancel(true) not working:

    Use this method for OnClientSelectedIndexChanged
    function RadListBox2_ClientSelectedIndexChanged(sender, args) { 
        __doPostBack('<%=RadListBox2.ClientID.Replace("_", "$") %>'''); 
    and set AutoPostBack="false" in the markup.

    The set_cancel was cancelling the event (it wouldn't hit the clientside SelectedIndexChanged), but it wasn't cancelling the postback (it would postback regardless of the cancel request).  This workaround will still hit your serverside OnSelectedIndexChanged handler.



  5. Genady Sergeev
    Admin
    Genady Sergeev avatar
    1600 posts

    Posted 21 Dec 2009 Link to this post

    Hi eakins05,

    We have already fixed the bug as you can check on the latest internal build. Information on how to obtain the latest internal can be found here.

    Sincerely yours,
    Genady Sergeev
    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.
Back to Top