format table values

This commit is contained in:
Ilion Beyst 2015-09-11 14:10:47 +02:00
parent 8d472c079b
commit 9fea3a6ca4
3 changed files with 18 additions and 4 deletions

View file

@ -16,6 +16,7 @@
//= require dataTables/extras/dataTables.responsive //= require dataTables/extras/dataTables.responsive
//= require dataTables/jquery.dataTables //= require dataTables/jquery.dataTables
//= require select2 //= require select2
//= require jquery-dateFormat
//= require turbolinks //= require turbolinks
//= require_tree . //= require_tree .

View file

@ -1,5 +1,4 @@
class DataTable class DataTable
def initialize user, params def initialize user, params
@user = user @user = user
@params = sanitize_params(params) @params = sanitize_params(params)
@ -15,11 +14,11 @@ class DataTable
data: data data: data
} }
end end
private private
def data def data
run_query(paginated_query.project(Arel.star)) run_query(paginated_query.project(Arel.star)).map do |record|
record.reject! {|k,v| k.is_a? Numeric} # Remove unneeded query results
end
end end
def count def count

View file

@ -61,6 +61,20 @@
{ data: 'peer', name: 'Peer', width: "15%", className: 'min-mobile'}, { data: 'peer', name: 'Peer', width: "15%", className: 'min-mobile'},
{ data: 'issuer', name: 'Issuer', width: "15%", className: 'min-desktop'}, { data: 'issuer', name: 'Issuer', width: "15%", className: 'min-desktop'},
{ data: 'message', name: 'Message', width: "45%", className: 'min-tablet-p'} { data: 'message', name: 'Message', width: "45%", className: 'min-tablet-p'}
],
columnDefs: [
{
targets: 0,
render: function(data, type, full, meta) {
return $.format.date(data, 'E dd/MM/yyyy HH:mm');
}
},
{
targets: 1,
render: function(data, type, full, meta) {
return data/100;
}
}
] ]
}); });