我需要點擊修改按鈕時,將我當前選中行的數據對應的賦值給dialog彈出的修改窗口,看一下代碼吧
{
text: '修改',
iconCls: 'icon-edit',
handler: function () {
var row = $('#tab').datagrid('getSelected');
if (row == null)
{
$.messager.alert("系統提示", "請選擇您要修改的數據!");
return;
}
if (row)
{
$("#txtLoginId").val(row.LoginId);
$("#txtLoginPwd").val(row.LoginPwd);
$("#txtUserStateId").val(row.UserStateId);
$("#txtTeacherName").val(row.TeacherName);
$('#txtSex').val(row.Sex);
$('#txtBirthday').val(row.Birthday.datebox('getValue'));
}
$("#divadd").show();
$("#divadd").dialog({
title: '修改',
width: 300,
height: 300,
closed: false,
cache: false,
modal: true,
buttons: [{
text: '保存',
iconCls: 'icon-save',
handler: function () {
var teacherid = row.teacherid;
var loginid = $("#txtLoginId").val();
var LoginPwd = $("#txtLoginPwd").val();
var UserStateId = $("#txtUserStateId").val();
var TeacherName = $("#txtTeacherName").val();
var Sex = $('#txtSex').datebox('getValue');
var Birthday = $('#txtBirthday').datebox('getValue');
$.ajax({
type:"post",
url: "Handler.ashx?type=2&TeacherId="+teacherid+"&loginId=" + loginid + "&LoginPwd=" + LoginPwd + "&UserStateId=" + UserStateId + "&TeacherName=" + TeacherName + "&Sex=" + Sex + "&Birthday=" + Birthday,
success: function (data) {
if (data == "ok") {
$.messager.alert("系統提示", "數據修改成功!");
showDate();
$('#divadd').dialog('close');
}
else {
$.messager.alert("系統提示", "數據修改失敗!");
return false;
}
}
})
}
}, {
text: '關閉',
iconCls: 'icon-cut',
handler: function () {
$('#divadd').dialog('close');
$("input").val('');
}
}]
})
}
沒有賦值成功,求賜教!
$('#txtBirthday').val(row.Birthday.datebox('getValue'));
你這個有問題。。row.Birthday不是easyui的datebox,你的Birthday是什麼內容,不是對象就直接下面的,是json對象獲取屬性值
$('#txtBirthday').val(row.Birthday);