Pagination, Template enhancements for datatables

- made template more flexible
- process pagination in reseller/ajax
- use datatables on /reseller
- add edit/delete buttons to template
agranig/1_0_subfix
Gerhard Jungwirth 13 years ago
parent 4c9c766380
commit ac9d981aa9

@ -32,7 +32,7 @@ sub list :Chained('/') :PathPart('reseller') :CaptureArgs(0) {
{id => 6, 'contract.id' => 6, name => 'reseller 6', status => 'terminated'},
];
$c->stash(resellers => $resellers);
$c->stash(template => 'reseller/list.tt');
$c->stash(template => 'reseller/listdt.tt');
NGCP::Panel::Utils::check_redirect_chain(c => $c);
}
@ -161,10 +161,17 @@ sub ajax :Chained('list') :PathPart('ajax') :Args(0) {
$row->{status}];
}
}
my $totalRecords = scalar(@$aaData);
#Pagination
if($iDisplayStart || $iDisplayLength ) {
my $endIndex = $iDisplayLength+$iDisplayStart-1;
$endIndex = $#$aaData if $endIndex > $#$aaData;
@$aaData = @$aaData[$iDisplayStart .. $endIndex];
}
$c->stash(aaData => $aaData,
iTotalRecords => scalar(@$aaData),
iTotalDisplayRecords => scalar(@$aaData));
iTotalRecords => $totalRecords,
iTotalDisplayRecords => $totalRecords);
$c->detach( $c->view("JSON") );
}

@ -10,12 +10,20 @@ $(document).ready(function() {
"bLengthChange": false,
"bSort": false,
"bInfo": true,
"sAjaxSource": "ajax/",
"iDisplayLength": 5,
"sAjaxSource": "[% c.uri_for( c.controller.action_for('ajax') ) %]",
"aoColumns": [
[% FOREACH f IN helper.column_fields -%]
{ "sName": "[% f %]" },
[% END -%]
{ "mRender": function ( data, type, full ) {
return '<a class="btn btn-small btn-primary" href="[% c.uri_for( c.controller.action_for("") ) %]/' +full[0]+'/edit"><i class="icon-edit" style="line-height:1em;margin-top:2px"></i>Edit</a>'+
' <a class="btn btn-small btn-secondary" href="[% c.uri_for( c.controller.action_for("") ) %]/' +full[0]+'/delete"><i class="icon-trash" style="line-height:1em;margin-top:2px"></i>Delete</a>';
},
"mData": null,
"sWidth": "132px"
}
],
} );
@ -40,14 +48,14 @@ $(document).ready(function() {
[% FOREACH t IN helper.column_titles -%]
<th>[% t %]</th>
[% END -%]
[% # one for actions -%]
<th></th>
</tr>
</thead>
<tbody>
[% FOREACH set IN helper.data -%]
<tr class="sw_action_row">
<td>Loading</td>
</tr>
[% END -%]
</tbody>
</table>
</div>

Loading…
Cancel
Save