jQuery使用EasyUi实现三级联动下拉框效果
其它的都不说,使用easyui实现三级联动主要就是一层套一层,大家且看代码
html表单
<input id="txtPipeRowName" style="width:150px;"> <input id="txtPipeName" style="width:150px;">
easyUi的Combobox:
// 一层Combo var srmCombx = $("#txtShouName")combobox({ loader:function(param,success,error){ $ajax({ url: '${CTX_ROOT}/TEquipmentsController?method=getEquipmentByParId&id='+selectSgId+'', dataType: 'json', success: function(data){ dataunshift({equipmentid:'',equipmentname:'全部'}); success(data); }, error: function(){ errorapply(this, arguments); } }); }, onSelect:function(record){ //onSelect 用户点击时触发的事件 在此的意义在于,用户点击一级后自动二级combobox piperowCombxcombobox({ loader:function(param,success,error){ $ajax({ url: '${CTX_ROOT}/TEquipmentsController?method=getEquipmentByParId&id='+$("#txtShouName")combobox("getValue")+'', dataType: 'json', success: function(data){ dataunshift({equipmentid:'',equipmentname:'全部'}); success(data); }, error: function(){ errorapply(this, arguments); } }); }, onSelect:function(record){ //这里也使用了onSelect事件,在二级combobox被用户点击时触发三级combobox pipeCombxcombobox({ loader:function(param,success,error){ $ajax({ url: '${CTX_ROOT}/TEquipmentsController?method=getEquipmentByParId&id='+$("#txtPipeRowName")combobox("getValue")+'', dataType: 'json', success: function(data){ dataunshift({equipmentid:'',equipmentname:'全部'}); success(data); }, error: function(){ errorapply(this, arguments); } }); }, valueField: 'equipmentid', textField: 'equipmentname', value:'', editable:false }); }, onLoadSuccess:function(){ //清空三级下拉框 就是成功加载完触发的事件 当一级combobox改变时,二级和三级就需要清空 pipeCombxcombobox("clear"); pipeCombxcombobox('setValue', '全部'); //给combobox下拉框设置一个值,否则为空不好看 }, valueField: 'equipmentid', textField: 'equipmentname', value:'', editable:false })combobox("clear"); //清空二级下拉框 }, valueField: 'equipmentid', textField: 'equipmentname', value:'', editable:false }); /*******************************/ //下面的俩个是组件, // 二层Combo var piperowCombx = $("#txtPipeRowName")combobox({ loader:function(param,success,error){ $ajax({ url: '${CTX_ROOT}/TEquipmentsController?method=getEquipmentByParId&id='+$("#txtShouName")combobox("getValue")+'', dataType: 'json', success: function(data){ dataunshift({equipmentid:'',equipmentname:'全部'}); success(data); }, error: function(){ errorapply(this, arguments); } }); }, valueField: 'equipmentid', textField: 'equipmentname', value:'', editable:false }); //三层Combo var pipeCombx=$("#txtPipeName")combobox({ loader:function(param,success,error){ $ajax({ url: '${CTX_ROOT}/TEquipmentsController?method=getEquipmentByParId&id='+$("#txtPipeRowName")combobox("getValue")+'', dataType: 'json', success: function(data){ dataunshift({equipmentid:'',equipmentname:'全部'}); success(data); }, error: function(){ errorapply(this, arguments); } }); }, valueField: 'equipmentid', textField: 'equipmentname', value:'', editable:false });
以上就是本文的全部内容,希望对大家的学习有所帮助,也希望大家多多支持安科网。
相关推荐
89427412 2020-02-13
0tx 2014-01-19
xx0cw 2019-10-27
小小大人物 2017-03-01
88324358 2016-03-18
海欣海夜 2015-03-20
黎豆子 2014-01-19
84483368 2012-10-16
崔博伦一路有你 2012-10-15
EdwardSiCong 2012-03-31
huzai 2012-02-23
shanhuijava 2011-07-31
lsxxx0 2017-08-06
83483768 2019-05-04
醉殇姒若梦遗年 2016-12-19
87407607 2013-12-24
88487901 2013-11-30
CleanData 2018-01-24