easyui添加编辑时下拉赋值
添加
编辑
var CRUD = {
add: function () {
var hDialog = top.jQuery.hDialog({
title: '添加', width: '70%', height: '80%', href: formurl, iconCls: 'icon-add',
onLoad: function () {
top.$('#txt_status').combobox({ url: '/sys/ashx/dichandler.ashx?categoryId=9', valueField: 'Title', textField: 'Title', editable: false, required: true, missingMessage: '', disabled: false });
top.$('#txt_is_die').combobox({ url: '/sys/ashx/dichandler.ashx?categoryId=10', valueField: 'Title', textField: 'Title', editable: false, required: true, missingMessage: '', disabled: false });
top.$('.kindeditor').kindeditor();//初始化kingdeditor编辑器
},
submit: function () {
//地区
var tp = top.$('#txtProvince').val();
var tc = top.$('#txtCity').val();
var ta = top.$('#txtArea').val();
top.$('#txt_sheng').val(tp);
top.$('#txt_shi').val(tc);
top.$('#txt_qu').val(ta);
//alert(top.$("#uiform").form('enableValidation').form('validate'));
//alert(top.$("#uiform").form('validate'));
//原来用的是这种方法 alert(top.$('#uiform').validate().form());
if (top.$("#uiform").form('validate')) {
var query = createParam('add', '0');
jQuery.ajaxjson(actionURL, query, function (d) {
if (parseInt(d) > 0) {
msg.ok('添加成功!');
hDialog.dialog('close');
grid.reload();
} else {
if (d == -1) {
top.$.messager.alert('提示', '该人员已存在,无法进行添加!', 'warning');
} else {
MessageOrRedirect(d);
}
}
});
return;
}
msg.warning('请填写必填项!');
return false;
}
});
top.$('#uiform').validate();
},
edit: function () {
var row = grid.getSelectedRow();
if (row) {
var hDialog = top.jQuery.hDialog({
title: '编辑', width: '70%', height: '80%', href: formurl, iconCls: 'icon-save',
onLoad: function () {
top.$('#txt_KeyId').numberspinner('setValue', row.KeyId);
top.$('#txt_ownner').numberspinner('setValue', row.ownner);
top.$('#txt_depid').numberspinner('setValue', row.depid);
top.$('#txt_status').combobox({ url: '/sys/ashx/dichandler.ashx?showType=noselected&categoryId=9', valueField: 'Title', textField: 'Title', editable: false, required: true, missingMessage: '', disabled: false, onLoadSuccess() { top.$('#txt_status').combobox('setValue', row.status); } });
top.$('#txt_is_die').combobox({ url: '/sys/ashx/dichandler.ashx?showType=noselected&categoryId=10', valueField: 'Title', textField: 'Title', editable: false, required: true, missingMessage: '', disabled: false, onLoadSuccess() { top.$('#txt_is_die').combobox('setValue', row.is_die); } });
top.$('#txt_name').textbox('setValue', row.name);
top.$('#txt_identNum').textbox('setValue', row.identNum);
top.$('#txt_disableNum').textbox('setValue', row.disableNum);
top.$('#txt_sex').textbox('setValue', row.sex);
top.$('#txt_nation').textbox('setValue', row.nation);
top.$('#txt_cardStatus').textbox('setValue', row.cardStatus);
top.$('#txt_disableKind').textbox('setValue', row.disableKind);
top.$('#txt_disableLevel').textbox('setValue', row.disableLevel);
top.$('#txt_disableReason').textbox('setValue', row.disableReason);
top.$('#txt_huKouKind').textbox('setValue', row.huKouKind);
top.$('#txt_phone').textbox('setValue', row.phone);
top.$('#txt_telphone').textbox('setValue', row.telphone);
top.$('#txt_address').textbox('setValue', row.address);
top.$('#txt_address_Reg').textbox('setValue', row.address_Reg);
top.$('#txt_guardianName').textbox('setValue', row.guardianName);
top.$('#txt_unitName').textbox('setValue', row.unitName);
top.$('#txt_sheng').val(row.sheng);
top.$('#txt_shi').val(row.shi);