如何在删除行时动态传递所有jqgrid单元格值
我对 JQGrid 很陌生,所以如果这是一个非常“废话”的问题,我提前道歉。
情况是当我删除网格中的一行时,jqgrid 只将参数 id 传递给 editurl。但是,在某些情况下,我需要多个 id 参数来删除一行,例如对于这样的网格:
{UserID, Message} => {(user1, "hello"),(user1, "hola"),(user2,"hi")}
如果我只想删除 (user1, "hello") 行,我需要 JQGrid 传递参数 UserID= user1 和 Message="hello" 否则 (user1, "hello") 和 (user1, "hola") 将被删除。
我已经尝试在删除之前使用 onClickSubmit 参数修改 url:
onclickSubmit: function(rp_ge, postdata){
rp_ge.url = 'RowManipulator.php?UserID='+$('#grid').getCell(postdata, 'UserID')+
'&Message='+$('#grid').getCell(postdata,'Message');
但是结果 url(检查 firebug 后)是:
RowManipulator.php?UserID=user1&Message=false
而不是 RowManipulator.php?UserID=user1&Message="hello"
。看来消息参数无法传递。
有谁知道如何实现我的意图?任何帮助将不胜感激
更新: 这是 jquery 代码:
jQuery(document).ready(function(){
jQuery("#list").jqGrid(
{ url:'DataFetcher.php',
datatype: 'xml',
mtype: 'GET',
colNames:['UserId','Message'],
colModel:[
{name:'UserId',index:'UserId',width:75, editable:false,align: 'left'},
{name:'Message',index:'Message',width:200, editable:true,align: 'left'}
],
pager: jQuery('#pager'),
rowNum:10,
rowList:[10,20,30],
sortname:'UserId',
sortorder: "asc",
viewrecords: true,
imgpath: 'jqgrid/css/images',
caption: 'MESSAGE',
editurl:'RowManipulator.php',
height: 350,
width: 1000});
jQuery("#list").jqGrid('navGrid','#pager',{},
{height:280,reloadAfterSubmit:true},
{height:280,reloadAfterSubmit:true},
{onclickSubmit: function(rp_ge, postdata){
rp_ge.url = 'RowManipulator.php?UserId='
$('#list').getCell(postdata, 'UserId') &&
Message=$('#list').getCell(postdata,Message);
},
reloadAfterSubmit:true},
{sopt:['cn','eq']})
I'm very new with JQGrid, so I apologize in advance if this a very 'duh' question..
The case is when I delete a row in the grid, jqgrid only pass the parameter id to the editurl. However, there are cases when I need more than one id parameter to delete a row, for instance for grid like this:
{UserID, Message} => {(user1, "hello"),(user1, "hola"),(user2,"hi")}
If i want to only delete the (user1, "hello") row, I need JQGrid to pass the parameter UserID=user1 and Message="hello" otherwise the (user1, "hello") and (user1, "hola") will be deleted.
I alreadt tried to modify the url before deleting by using onClickSubmit parameter:
onclickSubmit: function(rp_ge, postdata){
rp_ge.url = 'RowManipulator.php?UserID='+$('#grid').getCell(postdata, 'UserID')+
'&Message='+$('#grid').getCell(postdata,'Message');
However the resulted url (after checking on firebug) is:
RowManipulator.php?UserID=user1&Message=false
instead of RowManipulator.php?UserID=user1&Message="hello"
. It seems that the message paramater can't be delivered.
Does anyone have any idea how to achieve what I intended to? Any help will be very appreciated
Updated:
Here is the jquery code:
jQuery(document).ready(function(){
jQuery("#list").jqGrid(
{ url:'DataFetcher.php',
datatype: 'xml',
mtype: 'GET',
colNames:['UserId','Message'],
colModel:[
{name:'UserId',index:'UserId',width:75, editable:false,align: 'left'},
{name:'Message',index:'Message',width:200, editable:true,align: 'left'}
],
pager: jQuery('#pager'),
rowNum:10,
rowList:[10,20,30],
sortname:'UserId',
sortorder: "asc",
viewrecords: true,
imgpath: 'jqgrid/css/images',
caption: 'MESSAGE',
editurl:'RowManipulator.php',
height: 350,
width: 1000});
jQuery("#list").jqGrid('navGrid','#pager',{},
{height:280,reloadAfterSubmit:true},
{height:280,reloadAfterSubmit:true},
{onclickSubmit: function(rp_ge, postdata){
rp_ge.url = 'RowManipulator.php?UserId='
$('#list').getCell(postdata, 'UserId') &&
Message=$('#list').getCell(postdata,Message);
},
reloadAfterSubmit:true},
{sopt:['cn','eq']})
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
该行
有语法错误。
postdata
是否尚未包含“UserId”?然后$('#list').getCell(postdata, 'UserId')
将为您返回postdata
。尝试使用
或更好地使用
The line
has syntax errors. Is
postdata
not already contain the 'UserId'? Then$('#list').getCell(postdata, 'UserId')
will gives you backpostdata
.Try with
or better with