使用loadData方法:node
//JSP代碼: <input id='zdyReoprtNo' style="width:150px;height:26px" data-options="multiple:false,separator:',',editable:false"/> //JS代碼: $("#zdyReoprtNo").combobox({ valueField:'reoprtNo', textField:'reoprtName', panelHeight:'auto', width:100, }); var node=$("#tree").tree('getSelected');//這裏是根據easyui的tree被選中的節點動態的加載數據 var data = [];//建立數組 //數組添加值 data.push({reoprtNo:"1","reoprtName":"經濟指標表"}); data.push({reoprtNo:"2","reoprtName":"數量指標表"}); if(node.id == '03_02-02'){ data.push({reoprtNo:"4","reoprtName":"金額對比表"}); } data.push({reoprtNo:"3","reoprtName":"材料表"}); data.push({reoprtNo:"0","reoprtName":"所有"}); $('#zdyReoprtNo').combobox('loadData',data); var selectVal = $('#zdyReoprtNo').combobox('getValue'); if(selectVal && selectVal == '4' && node.id != '03_02-02'){ //下拉框沒有這個選項值,那麼清空下拉框被選中的值 $('#zdyReoprtNo').combobox('setValue',''); }