关于jQuery EasyUI datagrid删除传的参数的问题、、 datagrideasyuijavascript 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 你前台有selectedIds?你后台有selectedIds 接受吗。? 后台有的,我想问的是这个id是和数据库中表的id还是表格的id?如果是数据库表中的id应该在前台怎么写? 没看懂,你不是不是说没有。 $.post("deleteUsers.action?selectedIds="+ids 这个 selectedIds 是传到后台的。现在无论什么情况你 ids 必须有数据, 其次后台也能 取到 selectedIds 这个参数。 嗯嗯,我想问的问题就是这个ids是怎么来的?这个例子可以完成删除操作,数据库也是可以删除的,我就是看不懂,所以来问问,我把代码贴上来,帮我看下。前台:<script type="text/javascript"> $(document).ready(function() { initCommonJS(); $("#gridTable").datagrid({ url:'fetchPersonList.action?t=' + new Date(), width:750, sortName: 'name', sortOrder: 'desc', pagination:true, rownumbers:true, pageList:[15,30,50,100], columns:[[ {field:'id',title:'id',width:30,hidden:true}, {field:'ck',checkbox:true,width:30}, {field:'name',title:'姓名',width:80,sortable:true}, {field:'age',title:'年龄',width:60,align:'center',sortable:true} ]], toolbar:[{ id:'btnadd', text:'增加', iconCls:'icon-add', handler:function(){ checkOpenUrl("#gridTable","useredit.html",550,420,"增加","用户"); } },{ id:'btnremove', text:'删除', iconCls:'icon-remove', handler:function(){ checkSelectSomeDoFunc("#gridTable","删除","用户", function(ids){ $.post("deletePerson.action?selectedIds="+ids+"&t="+new Date(),{},function(result){ if (result=="success"){ $("#gridTable").datagrid("reload"); }else{ alert(result); } }); }, true ); } },{ id:'btnedit', text:'修改', iconCls:'icon-edit', handler:function(){ checkSelectOneOpenUrl("#gridTable","useredit.html",550,420,"修改","用户"); } }] }); }); </script></head><body><table id="gridTable"></table></body></html>后台:private IPersonService personService; private String selectedIds; private int total; private List<Person> rows=new ArrayList<Person>(); private int person_id; private String name; private int age;public void deletePersons() throws Exception{ System.out.println("开始删除了"+selectedIds); HttpServletResponse response = ServletActionContext.getResponse(); response.setContentType("text/html;charset=UTF-8"); try{ String[] ids = this.selectedIds.split(","); for (int i=0;i<ids.length;i++){ this.personService.delete(Integer.valueOf(ids[i])); } response.getWriter().write("success"); }catch(Exception ex){ System.out.println(ex); response.getWriter().write("删除用户出错!"); } } 虽然不知道他是怎么获取值的,但是把数据库中的表的字段改成ID就好了!!还是希望有人知道的告诉下小弟,谢谢。。告诉下获取值的原理!在action里面数出来看下,它获得的是数据库表中的id,并不是前台表格的id! 应该是框架在你选择了多个用户的时候自己构造出来的。你看ckbox列是否添加了事件? 关于javascript表单验证的效果问题 window.open 全屏问题 [object Object]是什么意思呢? 新手问题:关于marquee不能在浏览器中滚动的问题 如何实现跨域访问读xml 哈哈,终于升到小星了~~散分~~ 怎么样从表单中删除一个控件? 怎样在页面上把下拉列表的内容显示成只读阿!各位大虾帮忙阿!急!!!!!!!! 有关ASP和WSH运行时权限的问题。 用javascript如何修改注册表: javascript中有访问地图的API,API访问不了,请问什么问题? 两个按钮控制两个块的显隐,怎么打开页面时两个块就是隐藏的啊
你后台有selectedIds 接受吗。?
$.post("deleteUsers.action?selectedIds="+ids 这个 selectedIds 是传到后台的。
现在无论什么情况你 ids 必须有数据, 其次后台也能 取到 selectedIds 这个参数。
嗯嗯,我想问的问题就是这个ids是怎么来的?这个例子可以完成删除操作,数据库也是可以删除的,我就是看不懂,所以来问问,
我把代码贴上来,帮我看下。
前台:
<script type="text/javascript">
$(document).ready(function() {
initCommonJS();
$("#gridTable").datagrid({
url:'fetchPersonList.action?t=' + new Date(),
width:750,
sortName: 'name',
sortOrder: 'desc',
pagination:true,
rownumbers:true,
pageList:[15,30,50,100],
columns:[[
{field:'id',title:'id',width:30,hidden:true},
{field:'ck',checkbox:true,width:30},
{field:'name',title:'姓名',width:80,sortable:true},
{field:'age',title:'年龄',width:60,align:'center',sortable:true}
]],
toolbar:[{
id:'btnadd',
text:'增加',
iconCls:'icon-add',
handler:function(){
checkOpenUrl("#gridTable","useredit.html",550,420,"增加","用户");
}
},{
id:'btnremove',
text:'删除',
iconCls:'icon-remove',
handler:function(){
checkSelectSomeDoFunc("#gridTable","删除","用户",
function(ids){
$.post("deletePerson.action?selectedIds="+ids+"&t="+new Date(),{},function(result){
if (result=="success"){
$("#gridTable").datagrid("reload");
}else{
alert(result);
}
});
},
true
);
}
},{
id:'btnedit',
text:'修改',
iconCls:'icon-edit',
handler:function(){
checkSelectOneOpenUrl("#gridTable","useredit.html",550,420,"修改","用户");
}
}]
});
});
</script>
</head>
<body>
<table id="gridTable"></table>
</body>
</html>后台:
private IPersonService personService;
private String selectedIds;
private int total;
private List<Person> rows=new ArrayList<Person>();
private int person_id;
private String name;
private int age;
public void deletePersons() throws Exception{
System.out.println("开始删除了"+selectedIds);
HttpServletResponse response = ServletActionContext.getResponse();
response.setContentType("text/html;charset=UTF-8");
try{
String[] ids = this.selectedIds.split(",");
for (int i=0;i<ids.length;i++){
this.personService.delete(Integer.valueOf(ids[i]));
}
response.getWriter().write("success");
}catch(Exception ex){
System.out.println(ex);
response.getWriter().write("删除用户出错!");
}
}