After serializeeditdata, the parameter cannot be obtained in the Controller. It is always null.
Later, the extended modelbinder method was used.
It was strange that the binding failed. later it was found that controllercontext. httpcontext. Request. Form [bindingcontext. modelname] was empty. You cannot use controllercontext. httpcontext. Request. Form [0] to catch up with the progress.
Webpage
VaR editsettings = {
Closeafteredit: True,
Reloadaftersubmit: True,
Closeonescape: True,
Datatype: 'json ',
Serializeeditdata: function (postdata ){
Return JSON. stringify (postdata );
}
};
VaR addsettings = {
Closeafteradd: True,
Reloadaftersubmit: True,
Closeonescape: True,
Datatype: 'json ',
Serializeeditdata: function (postdata ){
Return JSON. stringify (postdata );
}
};
VaR delsettings = {
Reloadaftersubmit: True,
Closeonescape: True,
Datatype: 'json ',
Serializedeldata: function (postdata ){
Return JSON. stringify (postdata );
}
};
$ ("# Gridtable"). jqgrid ('navgrid', '# gridpager ',
{Add: True, EDIT: True, del: True, search: false },
Editsettings, // edit options
Addsettings, // Add options
Delsettings, // del options
{}// {Closeonescape: true}, // search options
// {Height: 250, jqmodal: false, closeonescape: true} // view options
);
Public class jqgridparameterbind <t>: imodelbinder
{
# Region imodelbinder Member
Public object bindmodel (controllercontext, modelbindingcontext bindingcontext)
{
VaR JSON = controllercontext. httpcontext. Request. Form [0] as string;
VaR JSS = new javascriptserializer ();
Return JSS. deserialize <dictionary <string, Object> (JSON );
}
}
Controller
[Httppost ()]
Public actionresult save ([modelbinder (typeof (jqgridparameterbind <dictionary <string, Object>)] dictionary <string, Object> postdata)
{
......
}