Asp.net JqGrid: Getting grid's EDIT post to go as Application/Json? -
i'm using jqgrid webforms website setup data [webmethod()]. that's working, need edit post send content "application/json", i'm having no luck. watching fiddler, see post go "application/x-www-form-urlencoded" - thought found , set correct options, it's still no-go.
here's grid setup:
$.extend($.jgrid.edit, { ajaxeditoptions: { contenttype: "application/json; charset=utf-8" }, }); jquery("#<%=jqgridname%>").jqgrid({ editurl: "/web/juicepress-misc-settings.aspx/savejpuserexception", ajaxgridoptions: { contenttype: "application/json; charset=utf-8", datatype: "json" }, ajaxeditoptions: { contenttype: "application/json; charset=utf-8", datatype: "json" }, prmnames: { search: "issearch", nd: null, rows: "numrows", page: "page", sort: "sortfield", order: "sortorder" }, // default values search make sure ajax call doesn't fail postdata: { searchstring: '', searchfield: '', searchoper: '' }, datatype: function(postdata) { $.ajax({ url: '/web/juicepress-misc-settings.aspx/getjpuserexceptions', type: "post", contenttype: "application/json; charset=utf-8", data: json.stringify(postdata), datatype: "json", success: function(data, st) { if (st == "success") { var grid = $("#<%=jqgridname%>")[0]; var griddata = data.d; grid.addjsondata(griddata); } }, error: function() { alert("error ajax callback"); } }); }, height: <%=height %>, width: <%=width %>, jsonreader: { id: "<%= keydatafield %>", //index of column pk in repeatitems: false }, colnames: [ <%= getcolumnheaders() %> ], colmodel: [ <%= getcolumns() %> ], multiselect: false, gridview: true, ignorecase: true, caption: "<%= gridtitle %>", gridcomplete: function(){ var ids = jquery("#<%=jqgridname%>").jqgrid('getdataids'); for(var i=0;i < ids.length;i++){ var cl = ids[i]; = "<input style='height:22px;width:20px;' type='button' value='e' onclick=\"jquery('#<%=jqgridname%>').editrow('"+cl+"');\" />"; se = "<input style='height:22px;width:20px;' type='button' value='s' onclick=\"jquery('#<%=jqgridname%>').saverow('"+cl+"');\" />"; jquery("#<%=jqgridname%>").jqgrid('setrowdata',cl,{act:be+se}); } } }); my service [webmethod] decorated method in page:
[webmethod()] public static void savejpuserexception(string name, string description, string oper, int id) { ... }
apparently editing in-line not use "ajaxeditoptions", instead uses "ajaxrowoptions" (go figure)...
so fix this:
ajaxrowoptions: { contenttype: "application/json; charset=utf-8", datatype: "json" }
Comments
Post a Comment