Datatable1.10: Server disconnected page, datatable1.10 page

Source: Internet
Author: User

Datatable1.10: Server disconnected page, datatable1.10 page

Next, the new feature of ableable1.10 in the previous article. For work requirements, We Need To paging the server.

I still take the Code directly .. Add comments to the code .. If you have any questions, give me some advice...

$ (Document). ready (function (){
Var table = $ ('# example'). DataTable ({
"Columns": _ tableCols,
"CreatedRow": xxxxxx, // function name
"Processing": true, // when the data is not fully loaded at once, the page displays loading in progress.
"ServerSide": true, // if it is set to true, the server page is displayed.
"PagingType": "full_numbers", // display form of the paging button
"Paging": true, // if it is FALSE, all data is displayed on a page.
"Ajax ":{
"Url": "xxxx/query ",
"Type": 'post ',
"Data": function (d ){
D. orderby = "position ";
},
"DataSrc": function (json ){
Return json. records;
},
},
});

});


// The above js Code is all written. If you need to add other attributes, such as lengthMenu, etc... See the server side processing URL for: http://datatables.net/manual/server-side


I use the springmvc framework. Therefore, the returned object must contain the recordsFiltered and recordsTotal long integer parameters. Otherwise, an error is reported (for example, the number of Showing 1 to 10 of 57 entries is NaN ). For more information, see the json data source on the official website. Therefore, the returned object should contain two parameters.

// RecordsFiltered is the total number of records in the data set after filtering
Private long recordsFiltered = 0;
// Total number
Private long recordsTotal = 0;

If you have any questions, please leave a message ....


The data source does not support data paging on the server.

F (! This. IsPostBack)
{
String newsTypeID = Request. QueryString ["TypeID"]. ToString ();
SqlConnection con = DB. createConnection ();
Con. Open ();
String sqlstr = "select * from newsTile where newsTypeID = '" + newsTypeID + "'";
SqlDataAdapter da = new SqlDataAdapter (sqlstr, con );
DataSet ds = new DataSet ();
Da. Fill (ds );
GridView1.DataSource = ds. Tables [0]. DefaultView;
GridView1.DataBind ();
}
That's all. You can see it clearly.

Good paging with server language or good JavaScript

Even without refreshing pages in ajax
It is also the frontend display of the page output data of background processing.
Instead of using js to implement Paging
You cannot put all the data on the front-end and use js to split the data. This means that a large amount of data is dead.

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.