Add the JQuery. dataTables table plug-in to jump to the specified page,

Source: Internet
Author: User

Add the JQuery. dataTables table plug-in to jump to the specified page,

I. Solutions

1. Add a custom toolbar and embed the text box

"Dom": 'l <"toolbar"> frtip ', // customize The toolbar // set The toolbar content // l-length changing input control // f-filtering input // t-The table! // I-Table information summary // p-pagination control // r-processing display element [javascript] view plain copy print? $ ("Div. toolbar "ingress .html ('<B style =" color: red "> jump to the </B> <input id =" searchNumber "/> <B style =" color: red; "> page </B> ');

2. Listen to the change event in the text box and execute the method for transferring the page of the plug-in.

// Tune to the specified page index. Note the case sensitivity var oTable = $ ('# example1'). dataTable (); oTable. fnPageChange (page );

3. After the plug-in is successfully drawn, bind the value of the text box

// Triggered when drawing, bind the value table of the text box. on ('draw. dt ', function (e, settings, data) {var info = table.page.info (); // If the page here is 0, console.info ('showing page:' + info. page + 'of' + info. pages); $ ('# searchNumber '). val (info. page + 1 );});

Ii. Complete sample code

<Table id = "example1" class = "table-hover table-striped"> <thead> <tr> <th> NO. </th> <th> name </th> <th> gender </th> <th> birthday </th> <th> class </th> </tr> </thead> </table> $ (function () {// note that the method is named able var table =$ ('# example1 '). dataTable ({"dom": 'l <"toolbar"> frtip ', // custom toolbar "pagingType": "full_numbers", lengthMenu: [3, 5, 10], processing: true, // whether to use progress bar serverSide: true, // whether to enable Database loading ajax: {url: '/tableone/getlist', type: 'post', data: function (d) {d. name = 'zhang san';/** custom aja parameter * special description. Here, you can override the default parameters of the control, such as the paging parameter * // d. start = 0; // lele.info (d); // var page = $ ('# searchnumber '). val (); // page = parseInt (page) | 1; // d. start = (page-1) * d. length ;}}, // specify the columns: [{data: 'sno'}, {data: 'sname'}, {data: 'ssex '}, {data: 'sbirthday'}, {data: 'class'}], order: [[3, 'desc']}); $ ("div. toolbar "ingress .html ('<B style =" color: red "> jump to the </B> <input id =" searchNumber "/> <B style =" color: red; "> page </B> '); // bind a page event ---- triggered when the page is switched. // table. on ('page. dt ', function () {// var info = table.page.info (); // lele.info ('showing page:' + info. page + 'of' + info. pages); //}); // triggered when drawing, bind the value table of the text box. on ('draw. dt ', function (e, settings, data) {var info = table.page.info (); // If the page here is 0, console.info ('showing page:' + info. page + 'of' + info. pages); $ ('# searchNumber '). val (info. page + 1) ;}); // modify the listening text box $ ('# searchnumber '). change (function () {var page = $ (this ). val (); page = parseInt (page) | 1; page = page-1; // you can call the specified page index, note the case sensitivity var oTable = $ ('# example1 '). dataTable (); oTable. fnPageChange (page );});});

Shown as follows:

The above section describes JQuery. the dataTables table plug-in is added to jump to the specified page. I hope it will help you. If you have any questions, please leave a message and I will reply to you in a timely manner. Thank you very much for your support for the help House website!

Large-Scale Price Reduction
  • 59% Max. and 23% Avg.
  • Price Reduction for Core Products
  • Price Reduction in Multiple Regions
undefined. /
Connect with us on Discord
  • Secure, anonymous group chat without disturbance
  • Stay updated on campaigns, new products, and more
  • Support for all your questions
undefined. /
Free Tier
  • Start free from ECS to Big Data
  • Get Started in 3 Simple Steps
  • Try ECS t5 1C1G
undefined. /

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.