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!