省市级联的数据回显

分享 已结 2 622
柠檬心茉莉情
悬赏:20飞吻
table.on('tool(houseAndCustomerTable)', function(house){
//省市级联数据回显
//得到后台省份数据
var province_select = 'dd[lay-value=' + data.province + ']';
//找到下拉框对应省份执行点击,为了使市渲染出来
$('#updateHouse_province').siblings("div.layui-form-select")
.find('dl').find(province_select).click();
//渲染(选中)后台省份数据
form.render('province_select','updateHouse_province');

//同上
var city_select = 'dd[lay-value=' + data.city.substr(0, data.city.indexOf('市')) + ']';
$('#updateHouse_city').siblings("div.layui-form-select")
.find('dl').find(city_select).click();
form.render('city_select','updateHouse_city');

//同上
var popedom_select = 'dd[lay-value=' + data.popedom + ']';
$('#updateHouse_popedom').siblings("div.layui-form-select")
.find('dl').find(popedom_select).click();
form.render('popedom_select','updateHouse_popedom');
});
回帖
  • 1.在弹窗的success回调中先加载省的下拉框,然后给省下拉框赋值 $("省").val(house.省);
    2.再根据house中省的值,查询渲染市下拉框,然后给市下拉框赋值 $("市").val(house.市);
    3.再根据house中市的值,查询渲染区下拉框,然后给区下拉框赋值 $("区).val(house.区);
    最后form.render("select","form的lay-filter的值");必须要重新渲染表格的,否则下拉框出不来值;
    1 回复
  • @菜鸟程序猿 对哒,都要执行click时间,不然市和区不会加载
    0 回复