##// END OF EJS Templates
datatables: use new way of generating labels for count of dynamic datatables....
marcink -
r2726:a9ece9dd default
parent child Browse files
Show More
@@ -22,21 +22,21 b''
22 22 $(document).ready(function() {
23 23 var $sshKeyListTable = $('#ssh_keys_table');
24 24
25 var getDatatableCount = function(){
26 var table = $sshKeyListTable.dataTable();
27 var page = table.api().page.info();
28 var active = page.recordsDisplay;
29 var total = page.recordsTotal;
30
31 var _text = _gettext("{0} out of {1} ssh keys").format(active, total);
32 $('#ssh_keys_count').text(_text);
33 };
34
35 25 // user list
36 26 $sshKeyListTable.DataTable({
37 27 processing: true,
38 28 serverSide: true,
39 ajax: "${h.route_path('admin_permissions_ssh_keys_data')}",
29 ajax: {
30 "url": "${h.route_path('admin_permissions_ssh_keys_data')}",
31 "dataSrc": function ( json ) {
32 var filteredCount = json.recordsFiltered;
33 var total = json.recordsTotal;
34
35 var _text = _gettext("{0} out of {1} ssh keys").format(filteredCount, total);
36 $('#ssh_keys_count').text(_text);
37 return json.data;
38 }
39 },
40 40 dom: 'rtp',
41 41 pageLength: ${c.visual.admin_grid_items},
42 42 order: [[ 0, "asc" ]],
@@ -75,11 +75,6 b''
75 75 $sshKeyListTable.css('opacity', 0.3);
76 76 });
77 77
78 // refresh counters on draw
79 $sshKeyListTable.on('draw.dt', function(){
80 getDatatableCount();
81 });
82
83 78 // filter
84 79 $('#q_filter').on('keyup',
85 80 $.debounce(250, function() {
@@ -43,23 +43,15 b''
43 43 <script type="text/javascript">
44 44
45 45 $(document).ready(function() {
46 var $userListTable = $('#fork_list_table');
46 var $forksListTable = $('#fork_list_table');
47 47
48 var getDatatableCount = function(){
49 var table = $userListTable.dataTable();
50 var page = table.api().page.info();
51 var active = page.recordsDisplay;
52 var total = page.recordsTotal;
53
54 var _text = _gettext("{0} out of {1} users").format(active, total);
55 $('#user_count').text(_text);
56 };
57
58 // user list
59 $userListTable.DataTable({
48 // fork list
49 $forksListTable.DataTable({
60 50 processing: true,
61 51 serverSide: true,
62 ajax: "${h.route_path('repo_forks_data', repo_name=c.repo_name)}",
52 ajax: {
53 "url": "${h.route_path('repo_forks_data', repo_name=c.repo_name)}",
54 },
63 55 dom: 'rtp',
64 56 pageLength: ${c.visual.dashboard_items},
65 57 order: [[ 0, "asc" ]],
@@ -92,23 +84,18 b''
92 84 }
93 85 });
94 86
95 $userListTable.on('xhr.dt', function(e, settings, json, xhr){
96 $userListTable.css('opacity', 1);
87 $forksListTable.on('xhr.dt', function(e, settings, json, xhr){
88 $forksListTable.css('opacity', 1);
97 89 });
98 90
99 $userListTable.on('preXhr.dt', function(e, settings, data){
100 $userListTable.css('opacity', 0.3);
101 });
102
103 // refresh counters on draw
104 $userListTable.on('draw.dt', function(){
105 getDatatableCount();
91 $forksListTable.on('preXhr.dt', function(e, settings, data){
92 $forksListTable.css('opacity', 0.3);
106 93 });
107 94
108 95 // filter
109 96 $('#q_filter').on('keyup',
110 97 $.debounce(250, function() {
111 $userListTable.DataTable().search(
98 $forksListTable.DataTable().search(
112 99 $('#q_filter').val()
113 100 ).draw();
114 101 })
General Comments 0
You need to be logged in to leave comments. Login now