我正在尝试向JqGrid表添加一个新行,服务器接收请求中发送的json。现在我尝试使用
将新参数添加到jsonpostData : {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"
});
答案 0 :(得分:1)
postData
将仅在填充网格时使用 (url
已定义且您使用datatype: "json"
或{{1} })。
如果您需要在网格编辑期间发布其他参数,则应使用与您使用的编辑模式相对应的选项或回调。您发布的代码使用单元格编辑(datatype: "json"
)。因此,您需要使用cellEdit: true
参数指定要将数据发布到的URL。您可以使用例如cellurl
回调来扩展将发送到URL的数据:
beforeSubmitCell
在上面的代码中,我另外替换了cellEdit: true,
cellurl: '/someUrl',
beforeSubmitCell: function () {
return { MyId: return $('#MyId').val() };
}