Delete all items from ComboBox - javascript

5 posts, 0 answers
  1. CHRIS
    CHRIS avatar
    2 posts
    Member since:
    Jan 2011

    Posted 10 Oct 2011 Link to this post

    I can add items to a comboBox - thru your excellent Telerik example.

    But I am trying to delete all items , this code deletes some , not all 

    function RemoveAllItems() 
        {
      
            var combo = $find('cboGarmentSize');
            var comboItems = combo.get_items();
              
            for (var i = 0; i < comboItems.get_count(); i++)
            {
                combo.trackChanges();
                var item = comboItems.getItem(i);
      
                combo.get_items().remove(item);
                combo.commitChanges();
                  
            }
               
        }
  2. Shinu
    Shinu avatar
    17764 posts
    Member since:
    Mar 2007

    Posted 11 Oct 2011 Link to this post

    Hello Chris,

    Try the following modified code.
    javascript:
    function RemoveAllItems()
       {
           var combo = $find('RadComboBox2');
           var comboItems = combo.get_items();
           for (var i = comboItems.get_count()-1; i>=0 ; i--)
             {
               combo.trackChanges();
               var item = comboItems.getItem(i);
               combo.get_items().remove(item);
               combo.commitChanges();
             }
        }

    Regards,
    Shinu.
  3. UI for ASP.NET Ajax is Ready for VS 2017
  4. CHRIS
    CHRIS avatar
    2 posts
    Member since:
    Jan 2011

    Posted 11 Oct 2011 Link to this post

    Hi Shinu,

    Fixed ,

    I see you have to remove the items from the "top" of the array first.
    Excellent work.

    Cheers Chris,


  5. Daniel Aquere
    Daniel Aquere avatar
    85 posts
    Member since:
    Mar 2011

    Posted 19 Feb 2014 in reply to Shinu Link to this post

    Hi Shinu and everyone,

    Please, how I delete all items with server side command?

    Thanks, best
  6. Daniel Aquere
    Daniel Aquere avatar
    85 posts
    Member since:
    Mar 2011

    Posted 19 Feb 2014 in reply to Daniel Aquere Link to this post

    I found... 

    Combobox.Items.Clear();

    tks
Back to Top
UI for ASP.NET Ajax is Ready for VS 2017