Is there a way to display a # row/line value that increases for each row displayed. I dont find an option to do this. Query that works in this plugin or plugin option.
Unfortunately, adding row numbers to tables is not possible with built-in features.
The front-end (JS) part of wpDataTables plays a significant role in the plugin’s functionality. Generally, front-end rendering is done by the DataTables jQuery plugin
All wpDataTables existing on the page are reflected in the global JavaScript object called ‘wpDataTables‘. If you check this variable in the JS developer console you will see the wpDataTables as properties of this object.
What you can do is to add one more column in your file or data source on the first spot then use this script on the page
<script type="text/javascript">
jQuery(window).on('load',function(){
wpDataTables.table_1.api().on( 'order.dt search.dt', function ( e, dt, type, indexes ) {
wpDataTables.table_1.api().column(0, {search:'applied', order:'applied'}).nodes().each( function (cell, i) {
cell.innerHTML = i+1;
}
);
}
).draw();
});
</script>
Please note that this will work only for non-server-side tables.
For server-side tables (manual) you already have the wdt_ID column which is an auto-increment column from wpDataTables created for crud functionality and (SQL based) tables where you can add one more column that will autoincrement.
The "wdt_ID" column is an automatically generated column for manual tables. Since you're pulling the data from the database, this column is not included.
However, you can still use the workaround provided in my previous response:
Add one more column in your file or data source on the first spot then use this script on the page
<script type="text/javascript">
jQuery(window).on('load',function(){
wpDataTables.table_1.api().on( 'order.dt search.dt', function ( e, dt, type, indexes ) {
wpDataTables.table_1.api().column(0, {search:'applied', order:'applied'}).nodes().each( function (cell, i) {
cell.innerHTML = i+1;
}
);
}
).draw();
});
</script>
Please note that this will work only for non-server-side tables, so you would need to disable "Server-side processing" if you want to use this.
Also, since wpDataTables is dynamically adding the back-ticks ( ` ) and semi-colon ( ; ), there's no need to include them in the query. My suggestion is to update your query to this:
SELECT protein, chemical, cas, organism FROM proteins
I have an empty 1st column, and have disabled server side processing and have added the javascript to the page, but i get a javascript error.
(index):51671 Uncaught TypeError: Cannot read properties of undefined (reading 'api') I had the javascript below the table, then moved it to the utmost footer, but still am getting the error. Not sure why api is undefined.
It works for me on on Chrome and Microsoft Edge but not on Firefox or Safari. Might just have to skip this alltogether as the solution does not work for all browsers
Is there a way to display a # row/line value that increases for each row displayed. I dont find an option to do this. Query that works in this plugin or plugin option.
Thanks
Hello Guillermo.
Thank you for your purchase.
Unfortunately, adding row numbers to tables is not possible with built-in features.
The front-end (JS) part of wpDataTables plays a significant role in the plugin’s functionality. Generally, front-end rendering is done by the DataTables jQuery plugin
All wpDataTables existing on the page are reflected in the global JavaScript object called ‘wpDataTables‘. If you check this variable in the JS developer console you will see the wpDataTables as properties of this object.
What you can do is to add one more column in your file or data source on the first spot then use this script on the page
Please note that this will work only for non-server-side tables.
For server-side tables (manual) you already have the wdt_ID column which is an auto-increment column from wpDataTables created for crud functionality and (SQL based) tables where you can add one more column that will autoincrement.
Kind Regards,
Aleksandar Vuković
[email protected]
Rate my support
wpDataTables: FAQ | Facebook | Twitter | Instagram | Front-end and back-end demo | Docs
Amelia: FAQ | Facebook | Twitter | Instagram | Amelia demo sites | Docs | Discord Community
You can try wpDataTables add-ons before purchasing on these sandbox sites:
Powerful Filters | Gravity Forms Integration for wpDataTables | Formidable Forms Integration for wpDataTables | Master-Detail Tables
My input data source type is SQL Query with server-side processing enabled.
My query looks like
SELECT proteins.`protein`,
proteins.`chemical`,
proteins.`cas`,
proteins.`organism`
FROM proteins;
How do I add wdt_ID. or do i just a dummy field for the Javascript to replace.
Hello Guillermo.
The "wdt_ID" column is an automatically generated column for manual tables. Since you're pulling the data from the database, this column is not included.
However, you can still use the workaround provided in my previous response:
Add one more column in your file or data source on the first spot then use this script on the page
Please note that this will work only for non-server-side tables, so you would need to disable "Server-side processing" if you want to use this.
Also, since wpDataTables is dynamically adding the back-ticks ( ` ) and semi-colon ( ; ), there's no need to include them in the query. My suggestion is to update your query to this:
Kind Regards,
Aleksandar Vuković
[email protected]
Rate my support
wpDataTables: FAQ | Facebook | Twitter | Instagram | Front-end and back-end demo | Docs
Amelia: FAQ | Facebook | Twitter | Instagram | Amelia demo sites | Docs | Discord Community
You can try wpDataTables add-ons before purchasing on these sandbox sites:
Powerful Filters | Gravity Forms Integration for wpDataTables | Formidable Forms Integration for wpDataTables | Master-Detail Tables
https://sandbox-3.metro.ucdavis.edu/search-results/
I have an empty 1st column, and have disabled server side processing and have added the javascript to the page, but i get a javascript error.
(index):51671 Uncaught TypeError: Cannot read properties of undefined (reading 'api')
I had the javascript below the table, then moved it to the utmost footer, but still am getting the error. Not sure why api is undefined.
All other pages are closed on the site.
Hello again Guillermo.
I don't see any errors on that page, and as far as I can see, the "counting" column works fine:
My advice would be to remove this column from filtering.
Kind Regards,
Aleksandar Vuković
[email protected]
Rate my support
wpDataTables: FAQ | Facebook | Twitter | Instagram | Front-end and back-end demo | Docs
Amelia: FAQ | Facebook | Twitter | Instagram | Amelia demo sites | Docs | Discord Community
You can try wpDataTables add-ons before purchasing on these sandbox sites:
Powerful Filters | Gravity Forms Integration for wpDataTables | Formidable Forms Integration for wpDataTables | Master-Detail Tables
It works for me on on Chrome and Microsoft Edge but not on Firefox or Safari. Might just have to skip this alltogether as the solution does not work for all browsers
Hello Guillermo.
You can add the timeout, like this:
If this doesn't work, please increase the timeout from 200 to 600 or more.
Kind Regards,
Aleksandar Vuković
[email protected]
Rate my support
wpDataTables: FAQ | Facebook | Twitter | Instagram | Front-end and back-end demo | Docs
Amelia: FAQ | Facebook | Twitter | Instagram | Amelia demo sites | Docs | Discord Community
You can try wpDataTables add-ons before purchasing on these sandbox sites:
Powerful Filters | Gravity Forms Integration for wpDataTables | Formidable Forms Integration for wpDataTables | Master-Detail Tables