donglei2022 2014-10-07 00:49
浏览 120
已采纳

jqgrid使用delData通过内联删除传递额外参数

I have a jqgrid with an inline delete button. This button sends a post to a php file which would, in turn, go delete the record from the database. Unfortunately, I cannot seem to figure out how to send additional data with the post call. I don't want to rely on the row number. Rather, I wish to add the value from a column (childId) to the POST.

Here is my table:

jQuery("#team").jqGrid({
    url: 'TeamRetrieval.php?userId='+userId,
    datatype: "json",
    colNames: ['User Id', 'Email', 'Created', 'Delete'],
    colModel: [
        {name: 'childId', index: 'childId', align: 'center', sorttype: 'string'},
        {name: 'user_email', index: 'user_email', align: 'center', sorttype: 'string'},
        {name: 'user_registered', index: 'user_registered', align: 'center', sorttype: 'string'},
        { name: 'delete', formatter: 'actions', width: 40, align:'center', sortable: false,
            formatoptions:{
                keys: true,
                editbutton: false,
                editformbutton: false,
                delbutton: true,
                delOptions: { url: 'TeamRetrieval.php?userId='+userId}
             }
        }                
    ],
    mtype: "GET",
    sortorder: 'asc',
    sortname: 'childId',
    caption: "Existing Team Members",
});

This seems to me like it should be pretty straightforward. I did find an option delData in the documentation here:

http://www.trirand.com/jqgridwiki/doku.php?id=wiki:form_editing&s[]=deldata

Another SO post showed Oleg suggesting delData can be used in the format options on an inline delete button, thus allowing one to pass additional parameters via the POST.

http://stackoverflow.com/questions/16798420/inline-delete-deloptions-how-to-add-additional-data-to-restful-post

However, there wasn't an example of how one would go about doing this. I'm pretty new to javascript (I come from java/c# land) and it isn't clear to me how to reference the column value from an array inside delData.

Could I please ask someone to explain how one would pass the value of the 'childId' column along in the POST which is made when the inline delete button is clicked?

  • 写回答

1条回答 默认 最新

  • duangao7133 2014-10-26 00:14
    关注

    Tony over at the jqgrid help forms was able to answer this. It is very easy to achieve what I describe, provided you know how to do it. =)

    In order to pass parameters with jqgrid's default delete functionality, one must identify the fields they wish to pass as keys. For example, note the key:true below:

    {name: 'childId', index: 'childId', align: 'center', sorttype: 'string', key:true}
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 对于相关问题的求解与代码
  • ¥15 ubuntu子系统密码忘记
  • ¥15 信号傅里叶变换在matlab上遇到的小问题请求帮助
  • ¥15 保护模式-系统加载-段寄存器
  • ¥15 电脑桌面设定一个区域禁止鼠标操作
  • ¥15 求NPF226060磁芯的详细资料
  • ¥15 使用R语言marginaleffects包进行边际效应图绘制
  • ¥20 usb设备兼容性问题
  • ¥15 错误(10048): “调用exui内部功能”库命令的参数“参数4”不能接受空数据。怎么解决啊
  • ¥15 安装svn网络有问题怎么办