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(","))
}

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

上一篇:用c#判断回文数和降序数


下一篇:判别模型、生成模型与朴素贝叶斯方法