我试图向JqGrid表中添加一个新行,在请求中发送的json将由服务器接收。现在,我尝试使用
postData : {my_parameter: "my_id"}但仍未发送my_parameter。
我还尝试保留mtype : "GET",但它仍然没有在json中发送我的自定义参数。你能帮帮我吗。
提前谢谢。
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"
});发布于 2015-01-30 15:19:15
如果使用非本地数据postData (定义了url并使用datatype: "json"或datatype: "json"),则只有在填充网格时才使用url。
如果在编辑网格的过程中需要发布附加参数,则应该使用相应于所使用的编辑模式的选项或回调。您发布的代码使用单元格编辑(cellEdit: true)。因此,您需要指定使用cellurl参数发布数据的URL。例如,您可以使用beforeSubmitCell回调来扩展将发送到URL的数据:
cellEdit: true,
cellurl: '/someUrl',
beforeSubmitCell: function () {
return { MyId: return $('#MyId').val() };
}在上面的代码中,我另外替换了cellurl
https://stackoverflow.com/questions/28236788
复制相似问题