Skip to content

Bootstrap-transfer populates only available column. #13

Description

@kheyros

Bootstrap-transfer doesn't allow to populate available or chosen column accordingly to incoming data. In order to do this, I changed the following lines :

// input: [{value:_, content:_}]
_this.$filter_input.val('');
for (var i in input) {
    var e = input[i];
    _this._remaining_list.push([{value:e.value, content:e.content}, true]);
    _this._target_list.push([{value:e.value, content:e.content}, false]);
}

to :

// input: [{value:_, content:_, selected:_}]
_this.$filter_input.val('');
for (var i in input) {
    var e = input[i];
    if (e.selected === true) {
        _this._remaining_list.push([{value:e.value, content:e.content}, false]);
        _this._target_list.push([{value:e.value, content:e.content}, true]);
    } else if (e.selected === false) {
        _this._remaining_list.push([{value:e.value, content:e.content}, true]);
        _this._target_list.push([{value:e.value, content:e.content}, false]);
    }
}

Then you juste need to provide a third parameter named "selected" for each option. It must be set to true to populate the "chosen" column or false for the "available" one.

Hope this will help.

You did a great job with this plugin, by the way. Thank you.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions