Pagination not showing
Pagination not showing
d_vineet
Posts: 19Questions: 0Answers: 0
Hi!
I have almost everything working except the pagination.
[code]
$(document).ready(function() {
$('#example').dataTable( {
"bPaginate": true,
"bProcessing": true,
"bServerSide": true,
"sAjaxSource": "{{=URL('MIS','get_serverside')}}",
} );
} );
[/code]
The data is rendered by a server side python script.
when I choose, e.g., "show 10 entries", then it correctly displays the first 10 entries page with the footer--
"Showing 1 to 10 of 10 entries (filtered from 4645 total entries)"
Only the pager is not displayed.
Maybe, I am missing something simple in my code.
Can anybody pl. point-out the mistake?
Thanks,
Vineet
I have almost everything working except the pagination.
[code]
$(document).ready(function() {
$('#example').dataTable( {
"bPaginate": true,
"bProcessing": true,
"bServerSide": true,
"sAjaxSource": "{{=URL('MIS','get_serverside')}}",
} );
} );
[/code]
The data is rendered by a server side python script.
when I choose, e.g., "show 10 entries", then it correctly displays the first 10 entries page with the footer--
"Showing 1 to 10 of 10 entries (filtered from 4645 total entries)"
Only the pager is not displayed.
Maybe, I am missing something simple in my code.
Can anybody pl. point-out the mistake?
Thanks,
Vineet
This discussion has been closed.
Replies
"sAjaxSource": "{{=URL('MIS','get_serverside')}}",
in the above code is correct.
It is a syntax used in 'web2py' framework which builds url.
in the zip file they are in media/images/ or https://github.com/DataTables/DataTables/tree/master/media/images (get "back" and "forward" images)
these are linked/specified in your CSS files, so make sure you have included CSS stylesheets.
[code]
/* example from http://www.datatables.net/release-datatables/media/css/demo_table.css */
.paginate_enabled_next {
background-image: url('../images/forward_enabled.jpg');
}
[/code]
Thanks for your reply.
The icons were not correctly referenced in the css file.
I have fixed it.
But still, the pagination is not showing.
Is there any other hint to solve this?
--Vineet
I will post the code here:
[code]
$(document).ready(function() {
$('#example').dataTable( {
"bPaginate": true,
"bProcessing": true,
"bServerSide": true,
"sAjaxSource": "{{=URL('MIS','get_serverside')}}",
} );
} );
Customer Database JSON serverside
Customer Name
Vehicle No
Model Name
Colour
Engine No
Chassis No
Date of Sale
City
Taluka
District
State
PIN
Home Unit
Dummy
Dummy
Dummy
[/code]
From the server side python script, a dictionary is returned like this--
[code]
def get_serverside():
----some code to get data from server----Then,-
D=dict(sEcho=sEcho, iTotalRecords=iTotalRecords, iTotalDisplayRecords=iTotalDisplayRecords, iDisplayLength=iDisplayLength, aaData=custdata_disp)
return response.json(D)
[/code]
The json output is like this (for page length of 10) --
[code]
{"aaData": [["field1", "field1","field2","field3","field4","field5","field6","field7","field8","field9","field10","field11","field12","field13","field14","field15", "field16"],....similar records......], "iDisplayLength": 10, "iTotalRecords": 4645, "sEcho": 1, "iTotalDisplayRecords": 10}
[/code]
I validated the json from jsonlint.com
(after all, the table is rendered correctly).
If this much code is not sufficient for you to troubleshoot, I will post it on a SVC.
Thanks,
Vineet
Let me work towards putting it on SVC.
After that, I will post a link here in this forum.
Thanks,
Vineet
Sorry for that.
Now I have initialized it with themeroller.
It looks great.
1) Page numbers in pager bar are just "clickable" texts (not buttons).
Is it by design?
OR should I include some images for page numbers, and first/prev/next/last links?
(maybe bcoz the back color of bars is very dark, human eye can not distinguish between button borders & back color of bar? If so, how to change the back color of themeroller?)
2) How do I stretch the search-bar at top & pager-bar at bottom to cover the full table width?
Currently the table is very wide but the bars are too short.
Thanks,
Vineet