2010-03-24 99 views
1

我想删除网格中的一行,但网格始终只发布id和操作符,我还想发布其他数据。jqGrid删除时的其他POST数据

我的jqgrid是这样的:

 
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

+0

这个问题是http://stackoverflow.com/questions/2833254/jqgrid-delete-row-how-to-send-additional -post数据 – 2010-10-15 11:37:57

回答

1

The id当你删除数据时应该与POST一起发送,应该对应于每行的rowId。要做到这一点,你需要在网格初始化为以下选项添加到.jqGrid({:的rootrow

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" 
}, 

值将取决于你的XML是如何命名的不同而不同。前面的示例将解析以下XML:

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

这有帮助吗?

+0

我使用Firebug删除当ROWID心不是发来的POST变量... 当编辑ROWID是发送一个POST变量... 这是我的问题 – Arizona2014 2010-03-24 17:34:17

+0

我使用的XML是基于jqgrid库的例子中提供的editing.php文件的例子,在飞行中创建。 – Arizona2014 2010-03-24 18:45:47

+0

您是否尝试使用上述方法,或者它不适合您? – 2010-03-24 20:04:05

1

引用你的问题 “我也想发布额外的数据”, 我假设你想在rowId和'del'旁边发布另一个变量。 您可以使用postext插件。这个插件提供了额外的API:setPostData(),setPostDataItem()等。