后台获取easyui datagrid其中一行数据
2018-02-20 20:04
483 查看
body代码
js代码
var t;
function deleteAdmin(){
var row = $("#tt").datagrid('getSelected');
if (null!=row){
t=row.a_id
//传递id 删除数据
$.ajax({
type: "POST",
url: "delectAdmin",
data: "id="+t,
});
//刷新jsp界面
location.reload();
return true;
}else{
alert("请选中你所要删除的行数据");
return false;
}
}
$(function() {
$("#tt").datagrid({
pageSize : 5,//每页显示的记录条数,默认为5
pageList : [ 5,8,10, 15, 20 ],//可以设置每页记录条数的列表
beforePageText: '第',//页数文本框前显示的汉字
afterPageText: '页 共 {pages} 页',
displayMsg: '第{from}到{to}条,共{total}条',
columns: [[
{
title: '序号', field: 'a_id',halign: 'center',align: 'center',width:100,id:'typ',
},
{
title: '用户名称', field: 'a_name',halign: 'center',align: 'center',width:100,
},
{
title: '用户密码', field: 'a_pwd',halign: 'center',align: 'center',width:100,
},
{
title: '邮箱', field: 'a_mail',halign: 'center',align: 'center',width:100,
},
{
title: '操作',field: 'action',halign: 'center',align: 'center',width: 200,
formatter: function (value,row,index) {
if (row.editing == true) {
return "<a href='#' onclick='saveRow(" + index + ");'>确定</a> <a href='#' onclick='reDo(" + index + ");'>取消</a>";
}
else {
return "<a href='#' onclick='return deleteAdmin();'>删除</a>";
}
}
}
]],
});
});
struts代码
action 代码
其中id需要getset 这样action 才能得到ajax传过来的值
js代码
var t;
function deleteAdmin(){
var row = $("#tt").datagrid('getSelected');
if (null!=row){
t=row.a_id
//传递id 删除数据
$.ajax({
type: "POST",
url: "delectAdmin",
data: "id="+t,
});
//刷新jsp界面
location.reload();
return true;
}else{
alert("请选中你所要删除的行数据");
return false;
}
}
$(function() {
$("#tt").datagrid({
pageSize : 5,//每页显示的记录条数,默认为5
pageList : [ 5,8,10, 15, 20 ],//可以设置每页记录条数的列表
beforePageText: '第',//页数文本框前显示的汉字
afterPageText: '页 共 {pages} 页',
displayMsg: '第{from}到{to}条,共{total}条',
columns: [[
{
title: '序号', field: 'a_id',halign: 'center',align: 'center',width:100,id:'typ',
},
{
title: '用户名称', field: 'a_name',halign: 'center',align: 'center',width:100,
},
{
title: '用户密码', field: 'a_pwd',halign: 'center',align: 'center',width:100,
},
{
title: '邮箱', field: 'a_mail',halign: 'center',align: 'center',width:100,
},
{
title: '操作',field: 'action',halign: 'center',align: 'center',width: 200,
formatter: function (value,row,index) {
if (row.editing == true) {
return "<a href='#' onclick='saveRow(" + index + ");'>确定</a> <a href='#' onclick='reDo(" + index + ");'>取消</a>";
}
else {
return "<a href='#' onclick='return deleteAdmin();'>删除</a>";
}
}
}
]],
});
});
struts代码
action 代码
其中id需要getset 这样action 才能得到ajax传过来的值
相关文章推荐
- EasyUI datagrid获取一行数据
- easyUI中datagrid中的formatter里面向后台发送请求获取数据
- easyUI 中datagrid控件从后台获取数据生成列,想让其中部分属性数据不在表中显示
- easyui中根据后台数据动态改变datagrid的列
- Easyui---datagrid编辑单元格及获取编辑前后数据
- EasyUI中datagrid获取json数据遇到的问题
- EasyUI单击选中一行数据并获取数据
- .net mvc3 + easyui datagrid 获取单页数据 无刷新分页
- easyui datagrid中插入一行数据注意一点
- EasyUI datagrid 获取全部数据
- [jQuery]EasyUI中DataGrid获取数据并分页
- easyui datagrid加载成功之后选定并获取首行数据
- EasyUI datagrid获取数据问题
- DataGrid选中任意一行,获取其中的信息
- easyui datagrid插件的getChecked方法,只能获取一行
- easyui datagrid加载成功之后选定并获取首行数据
- 在js中获取easyui datagrid的数据
- JqueryEasyUI datagrid通过struts请求从后台读取数据
- easyui datagrid获取选择行的数据
- CRM系统二期的dev(一)--EasyUi datagrid 获取Checked选择行(勾选行)数据