jQWidgets Forums

Forum Replies Created

Viewing 1 post (of 1 total)
  • Author
    Posts

  • emeade
    Member

    We are using this functionality in multiple forms so I’ve wrapped everything in a jQuery plugin. I’ve only included the relevant functions. The form is loaded in a jQuery modal…not sure if that is relevant.

    Here is a screenshot of the form.

    Delegate Button click:

    $('div.list_buttons').on('click', function(event){
    var clicked = $(event.target);

    var addAll = clicked.hasClass('jqxlist_addAll') || clicked.parents().hasClass('jqxlist_addAll');
    var removeAll = clicked.hasClass('jqxlist_removeAll') || clicked.parents().hasClass('jqxlist_removeAll');
    var add = clicked.hasClass('jqxlist_add') || clicked.parents().hasClass('jqxlist_add');
    var remove = clicked.hasClass('jqxlist_remove') || clicked.parents().hasClass('jqxlist_remove');

    if (add){
    addItems(that.options.sourceObj.selector, that.options.targetObj.selector);
    }
    else if(remove){
    removeItems(that.options.sourceObj.selector, that.options.targetObj.selector);
    }

    });

    Add Item(s) by clicking right arrow. Even when I set item.hasThreeStates on add the newly added item only has two states.

    addItems: function(source,target){
    var items = $(source).jqxListBox('getSelectedItems');

    for (var i = 0; i < items.length; i++) {
    item = items[i];
    item.hasThreeStates = true;

    $(target).jqxListBox('addItem', item);
    $(source).jqxListBox('removeAt', items[i].index);
    };

    $(source).jqxListBox('clearSelection');

    }

    Remove Item(s) by clicking left arrow. Only removing items where checked is null because this is the indeterminate state.

    removeItems: function(source,target){
    var items = $(target).jqxListBox('getItems');

    for (var i = 0; i < items.length; i++) {
    if (items[i].checked == null){
    $(source).jqxListBox('addItem', { label: items[i].label, value: items[i].value });
    $(target).jqxListBox('removeAt', items[i].index);
    }
    };
    }

    Basically, I need some way for users to remove items from the target listbox without using the checkbox. If I add a custom renderer to the target listbox that includes a remove button, would that work? Would I be able to capture a click of the button separate from checkbox selection?

    Thanks for the quick reply!

Viewing 1 post (of 1 total)