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

Item inserted client-side corrupts checked items.

3 Answers 27 Views
ListBox
This is a migrated thread and some comments may be shown as answers.
Jeanne
Top achievements
Rank 1
Jeanne asked on 05 Feb 2013, 08:56 PM
I have a radListBox with one item in it (loaded on the server side). That item is checked.

When I insert another item above it on the client side, the new item becomes the only checked item, and the existing checked item loses it's checked status, even though it still APPEARS to be checked. I AM using trackChanges and commitChanges.

To verify this:
Before inserting, display the value of rlbTest.get_checkedItems()[0].get_text(). It will display the text of the initial item.
After inserting a new item (not yet checked) at the same index as the existing item using itemList.insert(itemList.indexOf(oldItem), newItem) display the value of get_checkedItems()[0].get_text() again. It displays the value of the NEW item, even though that item is not yet checked! If you display get_checkedItems.length it will show 1.
Now set the new item checked, and commit the changes. Display the two values again. length is still only 1, and value is the value of the new item.
The old item still appears to be checked. Both items will return .get_checked() == true. But when posted back to the server, .GetCheckedIndices returns just ONE index - 0 (the new item).

Just found that the same problem appies to selected items!

3 Answers, 1 is accepted

Sort by
0
Nencho
Telerik team
answered on 08 Feb 2013, 01:04 PM
Hello Jeanne,

The issue you are facing is originated by the fact the you insert the new item with the index of item, which is already present in the RadListBoxItemsColletion. In order to overcome this behavior, I can suggest you to invoke the _updateCheckedIndices() function, in order to correctly update the ClientState of the control. Thus the index of the actually checked item would be the correct one.

All the best,
Nencho
the Telerik team
If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the RadControls for ASP.NET AJAX, subscribe to their blog feed now.
0
Jeanne
Top achievements
Rank 1
answered on 08 Feb 2013, 02:50 PM
The way you describe the cause of the problem makes it sound like there is something I am doing wrong, but in fact your code does not work like it should. If this is a known issue, why doesn't your insert at code call that

I worked around the problem by saving the values of all the checked items before inserting, and unchecking them. After the insert I recheck them by value. I'll try your solution when I get time, but I'm not a fan of using internal functions. It's too easy for updates to break the code.

If this is a known issue, why doesn't the insert function call that internal function automatically?
0
Nencho
Telerik team
answered on 13 Feb 2013, 02:40 PM
Hi Jeanne,

Your attempt of inserting certain item is absolutely correct. As you well guessed, the aforementioned private function should be called internally. As a token of gratitude for your involvement, I have updated your Telerik Points. In addition, the fix would be included in our upcoming release - Q1 2013, which is scheduled for 20th of February.

Kind regards,

Nencho
the Telerik team
If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the RadControls for ASP.NET AJAX, subscribe to their blog feed now.
Tags
ListBox
Asked by
Jeanne
Top achievements
Rank 1
Answers by
Nencho
Telerik team
Jeanne
Top achievements
Rank 1
Share this question
or