Arizona2014
Arizona2014

Reputation: 1347

jqGrid Additional POST datas when deleting

I want to delete a row in the grid, but the grid always post's only the id and oper, I also want to post additional data.

My jqgrid is something like :

jQuery("#editgrid").jqGrid({
url:'autoJSON.php', datatype: "xml", colNames:['RowID','Asigurator','Cilindree','Persoana', 'Perioada', 'Pret'], colModel:[ {name:'rowID',index:'rowID', width:60, editable:true}, {name:'idAsigurator',index:'idAsigurator', width:100, editable:true,editoptions:{size:20}},
{name:'cilindree',index:'cilindree', width:90, editable:true,editoptions:{size:20}}, {name:'persoana',index:'persoana', width:300,editable:true,edittype:"select",editoptions:{value:"Persoana juridica:Persoana juridica;Pensionar:Pensionar;Persoana fizica:Persoana fizica"}}, {name:'perioada',index:'perioada', width:120, align:"right",edittype:"select",editable:true,editoptions:{value:"12 luni:12 luni;6 luni:6 luni"}}, {name:'pret',index:'pret', width:80, align:"right",editable:true,editoptions:{size:20}} ], width:900, height:600, pager: '#pagered', sortname: 'rowID', viewrecords: true, sortorder: "desc", caption:"Autoturisme", editurl:"autoPOST.php", }); jQuery("#editgrid").jqGrid('navGrid',"#pagered",{edit:true,add:true,del:true});

What should I do to access in autoPOST.php rowID also as a post variable.

Thanks


When trying to delete the only post variables I see are oper='del' and id that returns the id of the selected row i want to delete

Upvotes: 1

Views: 1326

Answers (2)

Jimmy Merari
Jimmy Merari

Reputation: 143

Quoting your question "I also want to post additional data.", I assume you want to post another variable beside the rowId and 'del'. You can use postext plugin. This plugin provides additional API : setPostData(), setPostDataItem(), etc.

Upvotes: 1

Justin Ethier
Justin Ethier

Reputation: 134255

The id sent with the POST when you delete data should correspond to the rowId of each row. To make this happen, you need to add the following option to .jqGrid({ when the grid is intialized:

 xmlReader: {
            root:"xml", // Varies depending upon the structure of your XML
            row:"item", // Varies depending upon the structure of your XML
            repeatitems:false,
            id:"rowID"
}, 

Values of root and row will vary depending upon how your XML is named. The previous example will parse the following XML:

<xml>
 <item>
  <rowId>1</rowId>
  ...
 </item>
</xml>

Does that help?

Upvotes: 1

Related Questions