Convert Datatable into json to send foreground Implementation ideas _ javascript skills

Source: Internet
Author: User
To convert a able to json, You Can serialize dt to json and put it into the hidden control hidBoundary at the front end. The specific implementation is as follows, if you have similar requirements, refer to section 1. serialize dt into json and put it in the hidden control "hidBoundary" at the front end:

The Code is as follows:


String json = JsonConvert. SerializeObject (dtTemp );
This. hidBoundary. Value = json;


Newtonsoft. Json. dll needs to be referenced

2. obtain data in dt from the hidden space in the foreground

The Code is as follows:


Var boundaryDiv = $ ('# hidBoundary ');
If (boundaryDiv! = Undefined & boundaryDiv. length! = 0)
{
Var jsonString = boundaryDiv. val ();
_ JsonBoundary = jQuery. parseJSON (jsonString );
}


The parseJSON method of jQuery is used to parse data into json format.

And vice versa. If you want to convert the foreground json data to the background DataTable, use the opposite method.

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.