Dynamically setting paging info on initialisation
Dynamically setting paging info on initialisation
Hi all,
I have a very special requirement where I need to manually set the paging information displayed in datatables ("Showing x to y of z entries").
I discovered that I can use the plugin fnPagingInfo to get the data I need, and combine this with the datatables oLanguage/sInfo initialisation parameter (and so use my variable instead of the _END_ variable). So far so good.
I am struggling with passing in the variable from fnPagingInfo...this doesn't seem to work, and I am not sure what I am doing wrong. The code:
var oTable=$('#myTable').dataTable({
"oLanguage": { "sInfo": "Showing _START_ to "+this.fnPagingInfo().iTotal+" of _TOTAL_ entries"},
...
I am unable to get the total number through, and I get a javascript error...basically "this.fnPagingInfo().iTotal" is not working in this context (I do have the fnPagingInfo plug in included and am using it on the same page in other places without any errors).
Any ideas? It may be that I am using "this" incorrectly here? I have tried this without "this" , but I am getting the same result.
Thank you!
I have a very special requirement where I need to manually set the paging information displayed in datatables ("Showing x to y of z entries").
I discovered that I can use the plugin fnPagingInfo to get the data I need, and combine this with the datatables oLanguage/sInfo initialisation parameter (and so use my variable instead of the _END_ variable). So far so good.
I am struggling with passing in the variable from fnPagingInfo...this doesn't seem to work, and I am not sure what I am doing wrong. The code:
var oTable=$('#myTable').dataTable({
"oLanguage": { "sInfo": "Showing _START_ to "+this.fnPagingInfo().iTotal+" of _TOTAL_ entries"},
...
I am unable to get the total number through, and I get a javascript error...basically "this.fnPagingInfo().iTotal" is not working in this context (I do have the fnPagingInfo plug in included and am using it on the same page in other places without any errors).
Any ideas? It may be that I am using "this" incorrectly here? I have tried this without "this" , but I am getting the same result.
Thank you!
This discussion has been closed.
Replies
Your code doesn't work above since it is evaluated in the context of the function there the DataTable is initialised and run at that time only. It is not re-evaluated on every draw - that's what fnInfoCallback is used for :-)
Allan