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 乌班图ip地址配置及远程SSH
  • ¥15 怎么让点阵屏显示静态爱心,用keiluVision5写出让点阵屏显示静态爱心的代码,越快越好
  • ¥15 PSPICE制作一个加法器
  • ¥15 javaweb项目无法正常跳转
  • ¥15 VMBox虚拟机无法访问
  • ¥15 skd显示找不到头文件
  • ¥15 机器视觉中图片中长度与真实长度的关系
  • ¥15 fastreport table 怎么只让每页的最下面和最顶部有横线
  • ¥15 java 的protected权限 ,问题在注释里
  • ¥15 这个是哪里有问题啊?