views:

178

answers:

3

Hi, i have the problem that i can't send any identifier for the edited content to the edit.php file. it sends automaticaly an id=1 parameter for the first row in the grid for example...but this is not the same value as in mysql table column "id". the correct id is shown in the grid..it says id 3 in the first row, but when i edit data and save it, the grid id is shown as 1. how can i send and correct identifier to the edit.php?

Thanks in advance for your help.

this is the js code for the grid, the php part is working, only wrong parameter get's passed to it from the grid.

      jQuery("#statsgrid").jqGrid(
      {
   url:'modules/json.php?stats=true',
   datatype: 'json',
   mtype: 'POST',
    colNames:['ID', 'Nickname','Country', 'IP', 'Notes'], 
    colModel:
    [ 
     {name:'id',index:'id', width:90},
     {name:'nick',index:'nick', width:90},
     {name:'country',index:'country', width:80},  
     {name:'ip',index:'ip', width:100}, 
     {name:'note',index:'note', width:150, sortable:false, editable:true, editoptions:{size:10}} 
    ], 
   pager: '#statspager',
   rowNum:10,
   rowList:[10,20,30,50,100],
   sortname: 'nick',
   sortorder: 'desc',
   height: '100%',
   viewrecords: true,
   editurl: 'modules/edit.php',
   caption: 'Statistics'
  }).navGrid("#statspager",
  {}, //options 
  {height:280,reloadAfterSubmit:false,url:'modules/edit.php'}, // edit options 
  {height:280,reloadAfterSubmit:false}, // add options 
  {reloadAfterSubmit:false}, // del options 
  {} // search options 
  );
A: 

add an extra class name with the db id prefixed by some string:

<td class="something table_column_123">value</td>

And parse out table_column_123 when sending it back

Mark L
i dont get what you mean, sorry....i'm pretty much of a new when it comes to js. the correct id is shown in the grid, but the wrong one is passed to the edit.php...so how can i controll the postdata from the grid to edit.php?
A: 

Configure the JSONReader to use the DB id instead of a generated ID by adding:

jsonReader: {
    id: "id"
}

...to the call to jqGrid.

Note, however, that this is the default. If the grid isn't already picking up your IDs, then there's something going on which you haven't shown us, or the example above isn't actually what you're doing.

Craig Stuntz
yes, i just figured out what's wrong....i created the json data in a wrong way...i did nickname cells isntead of id cells. :D thanks for your help.
A: 

You could also try adding the "key" property to your ID row in the colmodel. See the documentation about it here

Ron Harlev