Remove Items on load

3 posts, 0 answers
  1. Eric Klein
    Eric Klein avatar
    183 posts
    Member since:
    Aug 2009

    Posted 03 May 2011 Link to this post

    I have two List boxes (Master and Child) on a screen that fill with data on load.  The first (Master) is loaded by looking at file stuctures and loading the names of all the files, the second (child) loads from a database and shows a list of files that have been previously selected. 

    All works fine but what I want to do is on if the user selects a record that already has data in the database I want to remove the matching files from the Master List, so the file name should only show once in either the master or child listbox.

    How do I remove items from the master on load.
  2. Gimmik
    Gimmik avatar
    170 posts
    Member since:
    May 2011

    Posted 05 May 2011 Link to this post

    Hi Eric,

    I was playing with the client-side events for the RadListBox not too long ago. The OnClientLoad event can probably be used to do what you want. I would write a javascript function and call it from the OnClientLoad event of RadListBox2. The function would then take the contents of RadListBox2, iterate through them while removing them from RadListBox1. Since RadListBox2 should be a subset of RadListBox1, it would always find the matching item (unless it has been removed from the filesystem.) In the case the file was deleted, there wouldn't be a match - but you can make that event work in your favor too. In the event a match isn't found in RadListBox1, I would fire off a function to remove the item from RadListBox2 (since it's no longer valid) and also delete that entry from the database so it won't be an issue next time.

    Here's a link to the documentation on the client-side OnClientLoad event:

    Here's a link to the documentation on the client-side methods that you use to modify RadListBox1:

    I hope this helps!
  3. Genady Sergeev
    Genady Sergeev avatar
    1600 posts

    Posted 06 May 2011 Link to this post

    Hello Gimmik,

    Both client-side and server-side item collections have remove method. You pass the item that you want to be removed to it. Here is an example (client side):

    var rlb = $find("RadListBox1");

    Best wishes,
    Genady Sergeev
    the Telerik team

    Browse the vast support resources we have to jump start your development with RadControls for ASP.NET AJAX. See how to integrate our AJAX controls seamlessly in SharePoint 2007/2010 visiting our common SharePoint portal.

Back to Top