Item inserted client-side corrupts checked items.

4 posts, 0 answers
  1. Jeanne
    Jeanne avatar
    58 posts
    Member since:
    Sep 2011

    Posted 05 Feb 2013 Link to this post

    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!
  2. Nencho
    Admin
    Nencho avatar
    1457 posts

    Posted 08 Feb 2013 Link to this post

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

    Posted 08 Feb 2013 Link to this post

    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?
  5. Nencho
    Admin
    Nencho avatar
    1457 posts

    Posted 13 Feb 2013 Link to this post

    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.
Back to Top