AI智能
改变未来

00031-layui 树形下拉选择 xmSelect(一):树数据一次加载

<div class=\"layui-form-item layui-form-item-my\" ><label class=\"layui-form-label\">行业</label><div class=\"layui-input-block\"><div id=\"industrySel\" ></div><input type=\"hidden\" name=\"industryId\" ><input type=\"hidden\" name=\"industry\"></div></div>
var industryTreeData = [];var rtnIndustry = admin.syncReq(ctx+\'/base/baseIndustryCategory/industryTreeList\',{});if(rtnIndustry.code==0){industryTreeData = rtnIndustry.data;}var industryXmSelect = xmSelect.render({el: \'#industrySel\',prop:{name:\'name\',value:\'id\'},clickClose:true,radio:true,filterable: true,data: industryTreeData,tree:{show:true,expandedKeys:[],strict:false,},on:function (data) {setTimeout(function () {var valueStr = industryXmSelect.getValue(\"valueStr\");var nameStr = industryXmSelect.getValue(\"nameStr\");if(valueStr){$(\"[name=industryId]\").val(valueStr);}else{$(\"[name=industryId]\").val(\"\");}if(nameStr){$(\"[name=industry]\").val(nameStr);}else{$(\"[name=industry]\").val(nameStr);}},500)}});var industryId = formData.industryId;if(industryId){industryXmSelect.setValue((\"\"+industryId).split(\",\"))}

效果:

赞(0) 打赏
未经允许不得转载:爱站程序员基地 » 00031-layui 树形下拉选择 xmSelect(一):树数据一次加载