I was wondering if the two following functionalities exist in WPDataTables - I wasn't able to find this in documentation so far.
- use window functions in the query - tried to do "row_number() over (partition by customer_id order by start_time asc) as rn", which resulted in an error.
- reference other tables previously created in the WPDataTables
Thank you for your purchase and sorry for the late response.
Unfortunately, adding a row number is not possible with the plugin's 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 serverside tables (manual) you have a wdt_ID column with 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.
What do you mean by referencing other tables previously created in wpDataTables?
Hi!
I was wondering if the two following functionalities exist in WPDataTables - I wasn't able to find this in documentation so far.
- use window functions in the query - tried to do "row_number() over (partition by customer_id order by start_time asc) as rn", which resulted in an error.
- reference other tables previously created in the WPDataTables
Thanks a lot for your help,
Pavol
Hello Pavol
Thank you for your purchase and sorry for the late response.
Unfortunately, adding a row number is not possible with the plugin's 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 serverside tables (manual) you have a wdt_ID column with 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.
What do you mean by referencing other tables previously created in wpDataTables?
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