如何在删除行时动态传递所有jqgrid单元格值

时间:2010-06-30 07:11:24

标签: jqgrid editing

我对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参数删除之前修改网址:

onclickSubmit: function(rp_ge, postdata){
    rp_ge.url = 'RowManipulator.php?UserID='+$('#grid').getCell(postdata, 'UserID')+
                '&Message='+$('#grid').getCell(postdata,'Message');

然而,结果网址(在检查萤火虫后)是:

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']})

1 个答案:

答案 0 :(得分:1)

该行

rp_ge.url = 'RowManipulator.php?UserId='
                         $('#list').getCell(postdata, 'UserId') &&
                         Message=$('#list').getCell(postdata,Message);

有语法错误。 postdata尚未包含'UserId'吗?然后$('#list').getCell(postdata, 'UserId')会返回postdata

尝试

rp_ge.url = 'RowManipulator.php?UserId=' +
             $('#list').getCell(postdata, 'UserId') +
             'Message=' + $('#list').getCell(postdata,'Message');

或更好

rp_ge.url = 'RowManipulator.php?' +
            jQuery.param({UserId: $('#list').getCell(postdata, 'UserId'),
                          Message: $('#list').getCell(postdata, 'Message')});
相关问题