Jqgrid transmits JSON parameters to the Controller

Source: Internet
Author: User
Tags jqgrid

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)

{

......

}

 

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.