How to remove items from a VirtualizingDataCollection

7 posts, 0 answers
  1. Jandieg
    Jandieg avatar
    43 posts
    Member since:
    Feb 2012

    Posted 16 Feb 2012 Link to this post

    I'm implementing a "remove item" method, which removes an item from the a listbox sourced by a VirtualizingDataCollection. How to remove items?
  2. Deyan
    Admin
    Deyan avatar
    2037 posts

    Posted 20 Feb 2012 Link to this post

    Hi Jandieg,

    Currently VirtualizingDataCollection does not support removing items from it. The idea of this collection is to provide an infrastructure for loading data items in portions depending on the scrolling position of the list box. It is initialized with a given count of numbers and loading page size and thus removing items from it would rather imply resetting the whole collection.

    However, could you please share some further details on your scenario so that we can evaluate it and consider upgrading the component to support this feature.

    Thanks for your time.

    Greetings,
    Deyan
    the Telerik team
    Sharpen your .NET Ninja skills! Attend Q1 webinar week and get a chance to win a license! Book your seat now >>
  3. DevCraft banner
  4. Jandieg
    Jandieg avatar
    43 posts
    Member since:
    Feb 2012

    Posted 20 Feb 2012 Link to this post

    Its a list of items with checkboxes where user can delete items. Similar to the standard email client.

    If I reload it can I scroll back to the latest position?

  5. Jandieg
    Jandieg avatar
    43 posts
    Member since:
    Feb 2012

    Posted 20 Feb 2012 Link to this post

    Or at least hide it...
    Maybe setting Visibility.Collapsed for all the checked items, would that work?
  6. Deyan
    Admin
    Deyan avatar
    2037 posts

    Posted 21 Feb 2012 Link to this post

    Hello Jandieg,

    Setting the Visibility property will not do the job since visual containers are reused and it will be recent on a subsequent realization of the same visual container.

    We will consider adding the ability to remove items from the collection though. This may happen for Q1 2012 SP1 at earliest.

    Let me know if this plan does not suite you so that we can think of a workaround that might be helpful in your scenario.

    Thanks for your time.

    Greetings,
    Deyan
    the Telerik team
    Sharpen your .NET Ninja skills! Attend Q1 webinar week and get a chance to win a license! Book your seat now >>
  7. Jandieg
    Jandieg avatar
    43 posts
    Member since:
    Feb 2012

    Posted 21 Feb 2012 Link to this post

    Let me check if you got my scenario:

    - User select items to remove
    - Press Remove button
    - Checked items are removed from server (in background)

    So I want to hide the items on the offline list, just temporarily because the next time the list is refreshed the removed items wont be there anymore.

    By "subsequent realization" you mean any additional items loaded to the list? (I use the LoadItems() method for incremental loading) Will that show again the hidden items?
  8. Deyan
    Admin
    Deyan avatar
    2037 posts

    Posted 23 Feb 2012 Link to this post

    Hello Jandieg,

    Setting any properties on a visual container would cause undesired behavior since the UI Virtualization mechanism reuses visual containers also for other data items that you might want to not be invisible.

    You can read more about how our UI virtualization mechanism works:

    http://blogs.telerik.com/deyanginev/posts/11-02-17/raddataboundlistbox-blending-ui-virtualization-smooth-scrolling-together.aspx

    If you hide visual containers and are sure that your end-users will not scroll the listbox, you can use this approach. However, since, I guess, this will not be the case, I simply suggest directly resetting the collection to reflect the change. As we are going to provide possibility to remove items from it without resetting it, this will only be a temporal solution for you.

    Since I also have noticed that you have opened a new support ticket regarding the same scenario, you can try sending me your project in that support thread so that I can directly take a look at your code and see how I can help.

    All the best,
    Deyan
    the Telerik team
    Sharpen your .NET Ninja skills! Attend Q1 webinar week and get a chance to win a license! Book your seat now >>
Back to Top
DevCraft banner