<input name="buyStatus" id="upbuyStatus" style=" 100%;height: 85%"/>//html
//调用二级联动方法
$(function () { combogridTwo("#upAdClass","#upAdPage");//连接地址二级联动方法封装 修改 combogridTwo("#adAdClass","#adAdPage");//连接地址二级联动方法封装 添加 }
/* * @Description combogrid 二级联动方法封装 * * @Author wzf * @Date 2018/10/27 10:03 * @Param * @return *combogridTwo("#upAdClass","#upAdPage") **/ function combogridTwo(oneId,twoId) { $(oneId).combogrid({ idField: 'id', textField: 'text', multiple: false,//单选 多选 editable:false,//定义用户是否可以直接输入文本到字段中。 fitColumns: true, panelHeight:'200px', url: base+'/xxxxxx/xxxxxx', columns: [[ {field:'ck',checkbox:true,40}, {field:'id',title:'广告链接地址类型',330}, {field:'text',title:'广告链接地址类型说明',330} ]], onSelect: function(index, row){ $(twoId).combogrid('clear');//<%--清除页码默认选中项--%> var url = base+'/xxxxx/xxxxxx?codeType='+row.id; $(twoId).combogrid('grid').datagrid('reload',url); } }) $(twoId).combogrid({ idField:'id', textField:'text', editable:false, multiple: false,//单选 多选 fitColumns: true, panelHeight:'200px', columns: [[ {field:'ck',checkbox:true,40}, {field:'id',title:'目的地地址',330}, {field:'text',title:'目的地地址说明',330} ]] }) }
给二级联动赋上默认值 (注意:必须在dialog打开之后赋值)
//二级联动设置默认值 if(data.xxxxx.adClass!=null&&data.xxxxx.adClass!=undefined&&data.xxxxx.adClass!=""){ $("#upAdClass").combogrid("setValue",data.xxxxx.adClass); var url = base+'/xxxxx/xxxxx?codeType='+data.xxxxx.adClass; $('#upAdPage').combogrid('grid').datagrid('reload',url); $("#upAdPage").combogrid("setValue",data.xxxxx.adPage); }