The method for adding the sequence number column to the jQuery Ables of the jQuery plug-in, jquerydatatables

Source: Internet
Author: User

The method for adding the sequence number column to the jQuery Ables of the jQuery plug-in, jquerydatatables

Official Website method example:

$ (Document ). ready (function () {var t = $ ('# example '). dataTable ({"columnDefs": [{"searchable": false, "orderable": false, "targets": 0}], "order": [[1, 'asc ']}); t. on ('order. dt search. dt ', function () {t. column (0, {search: 'applied ', order: 'applied '}). nodes (). each (function (cell, I) {cell. innerHTML = I + 1 ;});}). draw ();});

I tried it and found that the draw method could not be found. It may be due to a version problem and 1.12.10 is used.

So I found that some enthusiastic netizens could share some of the methods.

Define {"data": null, "targets": 0}, an empty column, and then add the method in dataTables:

"FnDrawCallback": function () {var api = this. api (); var startIndex = api. context [0]. _ iDisplayStart; // obtain the number of Apis starting from this page. column (0 ). nodes (). each (function (cell, I) {cell. innerHTML = startIndex + I + 1 ;});}

Web site: http://datatables.club/example/api/counter_columns.html

The above is a small Editor to introduce you to the jQuery plug-in dataTables to add sequence number columns, I hope to help you, if you have any questions, please leave a message, the small editor will reply to you in a timely manner. Thank you very much for your support for the help House website!

Related Article

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.