easyui combobox增加“不选”下拉项

combobox是一个下拉框,可以从下拉值中选取。但它没有取消选择的选项,选中以后无法让它为空。以下是要在下拉选项的最后增加一个“不选”的选项,点击它时可以把combobox置空。

示例代码:

$(‘#zh_dwdcb’).combobox({
disabled:false,
‘url’ : ‘<c:url value=”/nnmis/view/ddrz_xhgz/findAllDuanXhgzQueryList.tg”/>’,
valueField:’id’,
textField:’name’,
onLoadSuccess:function(data){
if(data[data.length-1].name!=’不选’){
data.push({“id”:””,”name”:”不选”});
$(this).combobox(‘loadData’,data).combobox(‘clear’);
}
},
onSelect:function(rec){
if(rec.name==’不选’){
$(‘#zh_dwdcb’).combobox(‘clear’);
}
}
});

飞信截图20150203152359

This entry was posted in Computer, javascript. Bookmark the permalink.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s