use serverside sorting in datatables

agranig/1_0_subfix
Gerhard Jungwirth 13 years ago
parent 6b64c732ac
commit f5afd4911b

@ -101,16 +101,29 @@ sub ajax_process :Private {
my $sSearch = $c->request->params->{sSearch} // ""; #/
my $iDisplayStart = $c->request->params->{iDisplayStart};
my $iDisplayLength = $c->request->params->{iDisplayLength};
my $iSortCol_0 = $c->request->params->{iSortCol_0};
my $sSortDir_0 = $c->request->params->{sSortDir_0};
#parse $data into $aaData
my $aaData = [];
for my $row (@$data) {
my @aaRow = @$row{@$columns};
#my %aaRow = %$row; #in case of using mData
if (grep /$sSearch/, @aaRow[@$searchable]) {
push @$aaData, \@aaRow;
}
}
#Sorting
if(defined($iSortCol_0) && defined($sSortDir_0)) {
if($sSortDir_0 eq "asc") {
@$aaData = sort {$a->[$iSortCol_0] cmp
$b->[$iSortCol_0]} @$aaData;
} else {
@$aaData = sort {$b->[$iSortCol_0] cmp
$a->[$iSortCol_0]} @$aaData;
}
}
my $totalRecords = scalar(@$aaData);
#Pagination
if($iDisplayStart || $iDisplayLength ) {

@ -8,7 +8,7 @@ $(document).ready(function() {
"bServerSide": true,
"bPaginate": true,
"bLengthChange": false,
"bSort": false,
"bSort": true,
"bInfo": true,
"iDisplayLength": 5,
"sAjaxSource": "[% c.uri_for( c.controller.action_for('ajax') ) %]",
@ -22,7 +22,8 @@ $(document).ready(function() {
' <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"
"sWidth": "132px",
"bSortable": false
}
],
} );

Loading…
Cancel
Save