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
Thanks,
Jared
4 Answers, 1 is accepted
0
eakins05
Top achievements
Rank 1
answered on 15 Dec 2009, 10:49 PM
Here's my current workaround:
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?
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?
0
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.
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.
0
eakins05
Top achievements
Rank 1
answered on 18 Dec 2009, 05:25 PM
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
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.
Use this method for OnClientSelectedIndexChanged
function RadListBox2_ClientSelectedIndexChanged(sender, args) { |
__doPostBack('<%=RadListBox2.ClientID.Replace("_", "$") %>', ''); |
} |
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.
0
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.
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.