easyui 弹出窗 急解决方法
easyui 弹出窗 急啊
点击表格中编辑按钮,弹出一个窗口,窗口里面有表格中的数据
修改窗口里面的数据,然后保存,改变表格中原来的值
function loadfzrygrid(){
$('#fzmc').datagrid({
title:"分组人员",
toolbar:'#fzmc_toolbar',
width:'auto',
height:580,
rownumbers:true,
columns:[[
{field:'ck',checkbox:true},
{field:'xm',title:'姓名',width:40,align:'center',formatter: function (value, rec) {
return rec.xm;
}},
{field:'xb',title:'性别',width:40,align:'center'},
{field:'sfzhm',title:'身份证号',width:120,align:'center'},
{field:'csny',title:'出生年月',width:80,align:'center'},
{field:'dz',title:'地址',width:80,align:'center'},
{field:'mz',title:'民族',width:40,align:'center'},
{field:'lxdh',title:'联系电话',width:70,align:'center'},
{field:'bm',title:'体检部门',width:60,align:'center'},
{field:'cz',title:'操作',width:40,formatter: function(value,row,index){
if(row){
return "<a href='javascript:void(0)' onclick='addryxx("+JSON.stringify(row)+")' >编辑</a>"
}
}
]],
});
}
-------------------------------------------------------------
这是我的表格,现在需要单击编辑按钮,弹出一个窗口,修改表格原有数据
求大神指点 急。。。
给个代码 谢谢
------解决思路----------------------
return "<a href='javascript:void(0)' onclick='addryxx("+JSON.stringify(row)+")' >编辑</a>"
传递index就好了,你JSON.stringify会传递一个新的json对象,而且如果你的row内容包含单引号回导致你的html代码出错,更新这个对象无用
传递index可以获取getRows获取所有行通过index下标获取到数据
return "<a href='javascript:void(0)' onclick='addryxx("+index+")' >编辑</a>"
dialog的保存后获取表单数据,调用updateRow更新datagrid数据
updateRow param Update the specified row, the param contains following properties:
index: the row index to be updated.
row: the new row data.
Code example:
$('#dg').datagrid('updateRow',{
index: 2,
row: {
name: 'new name',
note: 'new note message'
}
});
有空对看下API,http://www.jeasyui.com/documentation/index.php
点击表格中编辑按钮,弹出一个窗口,窗口里面有表格中的数据
修改窗口里面的数据,然后保存,改变表格中原来的值
function loadfzrygrid(){
$('#fzmc').datagrid({
title:"分组人员",
toolbar:'#fzmc_toolbar',
width:'auto',
height:580,
rownumbers:true,
columns:[[
{field:'ck',checkbox:true},
{field:'xm',title:'姓名',width:40,align:'center',formatter: function (value, rec) {
return rec.xm;
}},
{field:'xb',title:'性别',width:40,align:'center'},
{field:'sfzhm',title:'身份证号',width:120,align:'center'},
{field:'csny',title:'出生年月',width:80,align:'center'},
{field:'dz',title:'地址',width:80,align:'center'},
{field:'mz',title:'民族',width:40,align:'center'},
{field:'lxdh',title:'联系电话',width:70,align:'center'},
{field:'bm',title:'体检部门',width:60,align:'center'},
{field:'cz',title:'操作',width:40,formatter: function(value,row,index){
if(row){
return "<a href='javascript:void(0)' onclick='addryxx("+JSON.stringify(row)+")' >编辑</a>"
}
}
]],
});
}
-------------------------------------------------------------
这是我的表格,现在需要单击编辑按钮,弹出一个窗口,修改表格原有数据
求大神指点 急。。。
给个代码 谢谢
------解决思路----------------------
return "<a href='javascript:void(0)' onclick='addryxx("+JSON.stringify(row)+")' >编辑</a>"
传递index就好了,你JSON.stringify会传递一个新的json对象,而且如果你的row内容包含单引号回导致你的html代码出错,更新这个对象无用
传递index可以获取getRows获取所有行通过index下标获取到数据
return "<a href='javascript:void(0)' onclick='addryxx("+index+")' >编辑</a>"
var editIndex=-1;
function addryxx(index){
var row= $('#fzmc').datagrid('getRows')[index];
//打开dialog,给你的dialog里面的表单赋值什么的
editIndex=index;//////////更新正在编辑的数据下标
}
dialog的保存后获取表单数据,调用updateRow更新datagrid数据
function save(){
$('#fzmc').datagrid('updateRow',{index:editIndex,row:{/*字段名和表单的键值对对象*/}}
}
updateRow param Update the specified row, the param contains following properties:
index: the row index to be updated.
row: the new row data.
Code example:
$('#dg').datagrid('updateRow',{
index: 2,
row: {
name: 'new name',
note: 'new note message'
}
});
有空对看下API,http://www.jeasyui.com/documentation/index.php