jQWidgets Forums

jQuery UI Widgets Forums Lists ListBox adding new item with group doesnt add item to specified group

Tagged: ,

This topic contains 1 reply, has 2 voices, and was last updated by  Peter Stoev 12 years, 2 months ago.

Viewing 2 posts - 1 through 2 (of 2 total)
  • Author

  • elessar
    Participant

    hello,
    I’m filling the listbox dynamically, sorting items into to groups (let’s say group “1” and group “2”), but the following code (it is just example):

    source = []
         $("#listbox").jqxListBox({ source: source, checkboxes: true, width: 350, height: 250, theme: theme });
          var item1 = {
              label: "A",
              group: "1"
          }
          $("#listbox").jqxListBox('addItem', item1);
          var item2 = {
              label: "B",
              group: "2"
          }
          $("#listbox").jqxListBox('addItem', item2);
          var item3 = {
              label: "A",
              group: "1"
          }
          $("#listbox").jqxListBox('addItem', item3);

    doesn’t work, it puts everything (A,B,C) in just one group (“1”). I tried several workarounds, but none of them seems to work. Any idea?

    //edit: I guess I’d have to manually (with cycle or stg) determine which is the last item in specific group, remember its index and then insert my desired item to that position?


    Peter Stoev
    Keymaster

    Hi elessar,

    At present, the ‘addItem’ method just adds an item as a last item. It does not take into account whether you have set or not the ‘group’ field of the new item. For inserting an item at specific index, use ‘insertItem’ instead.

    Best Regards,
    Peter Stoev

    jQWidgets Team
    http://www.jqwidgets.com

Viewing 2 posts - 1 through 2 (of 2 total)

You must be logged in to reply to this topic.