javascript
  • php
  • jquery
  • jqgrid
  • delete-row
  • 2014-10-07 147 views 0 likes 
    0

    我有一个带内联删除按钮的jqgrid。这个按钮发送一个帖子到一个php文件中,然后这个文件将从数据库中删除记录。不幸的是,我似乎无法弄清楚如何在通话后发送更多的数据。我不想依靠行号。相反,我希望将来自列(childId)的值添加到POST。jqgrid传递额外的参数,并使用delData进行内联删除

    这里是我的表:

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

    这似乎对我来说,它应该是相当简单的。我发现这里的文档中的一个选项delData

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

    另一个SO后显示奥列格暗示delData可以在格式选项一起使用的内联删除按钮,从而使一个通过POST传递额外的参数。

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

    但是,没有人会这样做的例子。我很新的JavaScript(我来自java/c#土地),我不清楚如何引用delData中的数组的列值。

    请问有人解释如何在点击内联删除按钮时在POST中传递'childId'列的值?

    回答

    0

    托尼在jqgrid的帮助表单能够回答这个问题。如果你知道如何去做,很容易实现我所描述的内容。 =)

    为了使用jqgrid的默认删除功能传递参数,必须确定他们希望作为关键字传递的字段。例如,请注意下面的key:true

    {name: 'childId', index: 'childId', align: 'center', sorttype: 'string', key:true} 
    
    相关问题