【问题标题】:jqGrid Additional POST datas when deletingjqGrid 删除时的附加 POST 数据
【发布时间】:2010-03-24 09:13:59
【问题描述】:

我想删除网格中的一行,但是网格总是发布的只有id和oper,我还想发布额外的数据。

我的 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});

我应该怎么做才能在 autoPOST.php 中将 rowID 也作为 post 变量访问。

谢谢


当我试图删除我看到的唯一的帖子变量是 oper='del' 和 id 返回我要删除的所选行的 id

【问题讨论】:

标签: jqgrid rowdeleting


【解决方案1】:

删除数据时随 POST 发送的id 应与每一行的rowId 对应。为此,您需要在网格初始化时将以下选项添加到.jqGrid({

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

rootrow 的值将根据 XML 的命名方式而有所不同。前面的示例将解析以下 XML:

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

这有帮助吗?

【讨论】:

  • 我正在使用 FIREBUG,删除时 rowID 没有作为 POST 变量发送...编辑时 rowID 作为 POST 变量发送...这是我的问题
  • 我使用的XML是根据jqgrid库示例中提供的editing.php文件示例动态创建的。
  • 您是否尝试过使用上述方法,或者它不适合您?
【解决方案2】:

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

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2014-03-26
    • 2012-04-10
    • 1970-01-01
    • 2012-09-23
    • 2015-05-21
    相关资源
    最近更新 更多