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}
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥60 版本过低apk如何修改可以兼容新的安卓系统
  • ¥25 由IPR导致的DRIVER_POWER_STATE_FAILURE蓝屏
  • ¥50 有数据,怎么建立模型求影响全要素生产率的因素
  • ¥50 有数据,怎么用matlab求全要素生产率
  • ¥15 TI的insta-spin例程
  • ¥15 完成下列问题完成下列问题
  • ¥15 C#算法问题, 不知道怎么处理这个数据的转换
  • ¥15 YoloV5 第三方库的版本对照问题
  • ¥15 请完成下列相关问题!
  • ¥15 drone 推送镜像时候 purge: true 推送完毕后没有删除对应的镜像,手动拷贝到服务器执行结果正确在样才能让指令自动执行成功删除对应镜像,如何解决?