87,921
社区成员
发帖
与我相关
我的任务
分享
department = $("#department").ligerComboBox({
width: 150,
selectBoxWidth: 150,
selectBoxHeight: 150,
valueField: 'id',
textField: 'text',
treeLeafOnly: false,
initValue: obj.department_id,
tree: {
onSuccess: function () {
//var manager = $(".l-tree").ligerGetTreeManager();
//manager.clear();
},
url: '../data/department.ashx?Action=deptree&company_id=' + obj.company_id + '&rnd=' + Math.random(),
usericon: 'icon',
idFieldName: 'id',
checkbox: false
}
});
$(function () {
$.metadata.setType("attr", "validate");
tpyzq.validate($(form1));
$("form").ligerForm();
if (getparastr("id")) {
loadForm(getparastr("id"));
}
});
function loadForm(id) {
$.ajax({
type: "GET",
url: "../data/employee_view.ashx",
data: { Action: 'form', id: id, rnd: Math.random() },
contentType: "application/json; charset=utf-8",
dataType: "json",
success: function (result) {
var obj = eval(result);
for (var n in obj) {
if (obj[n] == "null" || obj[n] == null)
obj[n] = "";
}
$("#company").ligerComboBox({
width: 495,
url: "../data/company.ashx?Action=combo&rnd=" + Math.random(),
//emptyText: '(空)',
initValue: obj.company_id,
onSelected: function (company_id, company) {
change_department(company_id, company, obj.department_id);
}
});
$("#name").val(obj.name);
$("#sex").val(obj.sex);
}
});
}
function change_department(company_id, company, department_id) {
$("#d_department").html(" <input type='text' id='department' name='department' ligerui='{width:196}' />");
department = $("#department").ligerComboBox({
width: 150,
selectBoxWidth: 150,
selectBoxHeight: 150,
valueField: 'id',
textField: 'text',
treeLeafOnly: false,
initValue: department_id,
tree: {
url: '../data/department.ashx?Action=deptree&company_id=' + company_id + '&rnd=' + Math.random(),
onSuccess:function(data){
if (data.length <= 1) {
$("#department").val("无");
}
},
usericon: 'icon',
idFieldName: 'id',
checkbox: false
}
});
}
<div id="lb"><input type="text" id="txt1" /></div>
$('#lb').html('<input type="text" id="txt1" />')//重置dom元素
$("#txt1").ligerComboBox({//重新生成cb,注意设置数据源和相关配置
width: 180,
selectBoxWidth: 200,
selectBoxHeight: 200, valueField: 'text', treeLeafOnly: false,
tree: { url: '../tree/json.txt', ajaxType: 'get' }
});;