首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >postData不在JqGrid工作

postData不在JqGrid工作
EN

Stack Overflow用户
提问于 2015-01-30 13:16:45
回答 1查看 1.2K关注 0票数 0

我试图向JqGrid表中添加一个新行,在请求中发送的json将由服务器接收。现在,我尝试使用

代码语言:javascript
复制
postData : {my_parameter: "my_id"}

但仍未发送my_parameter

我还尝试保留mtype : "GET",但它仍然没有在json中发送我的自定义参数。你能帮帮我吗。

提前谢谢。

代码语言:javascript
复制
   jQuery(grid_selector).jqGrid({
    data: griddata,
    datatype: "local",
    height: "auto",
    colNames:[' ', 'ID','Activity Name', 'Phase'],
    colModel:[
        {name:'myac',index:'', width:80, fixed:true, sortable:false, resize:false,
            formatter:'actions',
            formatoptions:{
                keys:true,
                //delbutton: false,//disable delete button

                delOptions:{recreateForm: true, beforeShowForm:beforeDeleteCallback},
                //editformbutton:true, editOptions:{recreateForm: true, beforeShowForm:beforeEditCallback}
            }
        },
        {name:'id',index:'id', width:60, sorttype:"int", editable: true},
        {name:'name',index:'name', width:150,editable: true,edittype:"select",editoptions:{value:activity_val}},
        {name:'phase',index:'phase', width:90, editable: true,edittype:"select",editoptions:{value:"Phase1:Phase I;Phase2:Phase II;Other:Other"}},
    ],

    viewrecords : true,
    rowNum:20,
    rowList:[10,20,30],
    pager : pager_selector,
    altRows: true,
    gridview: true,
    //toppager: true,

    multiselect: false,
    //multikey: "ctrlKey",
    multiboxonly: true,

    loadComplete : function() {
        var table = this;
        setTimeout(function(){
            styleCheckbox(table);

            updateActionIcons(table);
            updatePagerIcons(table);
            enableTooltips(table);
        }, 0);
    },
    editurl: '/del_row/',//nothing is saved
    cellEdit: true,
    postData: {MyId :function() { return $('#MyId').val();}},
    caption: "Activty Phase Mapping"
});
EN

回答 1

Stack Overflow用户

发布于 2015-01-30 15:19:15

如果使用非本地数据postData (定义了url并使用datatype: "json"datatype: "json"),则只有在填充网格时才使用url

如果在编辑网格的过程中需要发布附加参数,则应该使用相应于所使用的编辑模式的选项或回调。您发布的代码使用单元格编辑(cellEdit: true)。因此,您需要指定使用cellurl参数发布数据的URL。例如,您可以使用beforeSubmitCell回调来扩展将发送到URL的数据:

代码语言:javascript
复制
cellEdit: true,
cellurl: '/someUrl',
beforeSubmitCell: function () {
    return { MyId: return $('#MyId').val() };
}

在上面的代码中,我另外替换了cellurl

票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/28236788

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档