user765368
user765368

Reputation: 20346

remove data from jquery easyui combobox

I'm using the jQuery EasyUI Combobox to present a list of data. Is there any way I can remove a particular line from my jQuery EasyUI combobox list with a jQuery EasyUI function or something?

Upvotes: 4

Views: 4733

Answers (2)

jinglong
jinglong

Reputation: 1

I didn't find special function, but can use 'getData' and 'loadData' do it.

var items = $("#id").combobox('getData');
var newItems = [];
//push the select option if value is not equals '1'
$.each(items, function (index, item) {
    if (item.value != '1') {
        newItems.push(item);
    }
});
$("#id").combobox('loadData', newItems);

generally, u may change the selected option. I use below code select the first one.

var opts = $("#id").combobox('options');
$("#id").combobox('setValue', newItems[0][opts.valueField]);

Upvotes: 0

Mateusz
Mateusz

Reputation: 99

Hello i didn't find special function for that in EasyUI Combobox, but you can use JQuery selectors

this is the way to delete selected item:

$('.combobox-item-selected').remove(); // Remove selected item
$('.combo-text').val(''); // clear a textfield

this is the way to delete any item by unique value using selectors:

$('div[value="ND"]').remove(); // Where ND is unique value

i tried this code in this demo of EasyUI Combobox

Greetings

Upvotes: 3

Related Questions