公司已封装easyUi下拉框,组合框

来源:互联网 发布:酷听说软件下载 编辑:程序博客网 时间:2024/06/05 02:52

1.

已封装好easycombobox.js 有create方法和init方法

var EC = require("resource/js/component/easycombobox.js");


//从tbl_base_code 中查询,条件是base_type  in(‘status’,‘XX’)

EC.create({
url:BASEPATH+"/base/authoriza/basecode/getType.htm",
param:{checkeds:"status,xx"}

});

EC.init({ ele:"#searchState", grouptype:"status" });  // 遍历类型,如果不写会把checkeds内所有都遍历

jsp中有下拉定义

   <div class="groundform clear">
          <label>可用状态:</label>
          <div class="inputWidth">
                <input id="searchState" name="sfyx">
          </div>
     </div>

遍历status         valueField :base_code  

                                                textField: base_name   默认 请选择

例如 0  可用

        1 不可用

2.

异步请求取出数据然后遍历

searchBsType("contentId","selectId","content");//选项下拉列表

function searchBsType(id,value,text){
using("combobox",function(){
ajax.init().success(function(code,msg,data){//异步取出选项对象
if(data){
combobox.init(
{ ele:"#"+id,
valueField:value,            //value
textField:text,                   //显示
remote:false,
emptyval:true
}
).load(data);
}
}).post(BASEPATH+'/bm/quest/queryQuestById.htm',{questId:$("#questId").val()});
});
}

jsp:

<div class="groundform clear" id="selectContent">
<label>选项:</label>
<div class="inputWidth">
<input class="easyui-combobox" id="contentId" name="selectId" data-options="prompt:'请选择选项',editable:'true'"/>
 </div>
</div>

3.

var data = [{id:"",name:"请选择"},{id:"0",name:"单选"}, {id:"1",name:"多选"},{id:"2", name:"问答"}];
$("#types").combobox({
valueField:'id',
textField:'name',
editable:false,
data:data,     //被加载的列表数据
onSelect:function(record){                   //选中后触发事件
if(record.name=="问答"){
$("#txt1,#txt2,#txt3,#txt4").hide();
}else{
$("#txt1,#txt2,#txt3,#txt4").show();
}
}
});

jsp:

<tr>
<td class='key'><span>*</span>类型:</td>
<td>
<input type="easyui-combobox" name="type" id="types" style="width: 400px;" data-options="required:true"/>
</td>
</tr>

4.

设置组合框(combobox)值的数组。
代码实例:

  1. $('#cc').combobox('setValues', ['001','002']);
设置组合框(combobox)的值。
代码实例:
  1. $('#cc').combobox('setValue', '001');

原创粉丝点击