4

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?

JK.
  • 21,477
  • 35
  • 135
  • 214
user765368
  • 19,590
  • 27
  • 96
  • 167

2 Answers2

3

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

Mateusz
  • 99
  • 8
0

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]);
jinglong
  • 1
  • 2