tags:

views:

77

answers:

1

Dear All,

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

The line

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

has syntax errors. Is postdata not already contain the 'UserId'? Then $('#list').getCell(postdata, 'UserId') will gives you back postdata.

Try with

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

or better with

rp_ge.url = 'RowManipulator.php?' +
            jQuery.param({UserId: $('#list').getCell(postdata, 'UserId'),
                          Message: $('#list').getCell(postdata, 'Message')});
Oleg
Hi Oleg, I've tried your answer and I still get the same problem, the UserId parameter is passed successfully but the Message parameter is passed as "false".. any idea?
Dorian
Oleg
Hi Oleh,Many Thanks for the answer, I've checked again and everything works well, it turns out that JqGrid is case-sensitive in terms of the the column naming, that is the reason why I got "false" as the value.
Dorian