Make transaction datatable actually work

This commit is contained in:
Ilion Beyst 2015-09-08 17:46:07 +02:00
parent c3c13f428a
commit 20bb280482
3 changed files with 7 additions and 10 deletions

View file

@ -1,6 +1,7 @@
class TransactionsController < ApplicationController
def index
p params
respond_to do |format|
format.html
format.json { render json: TransactionDatatable.new(view_context) }

View file

@ -1,12 +1,10 @@
class TransactionDatatable < AjaxDatatablesRails::Base
def sortable_columns
# Declare strings in this format: ModelName.column_name
@sortable_columns ||= []
@sortable_columns ||= ['Transaction.id']
end
def searchable_columns
# Declare strings in this format: ModelName.column_name
@searchable_columns ||= []
end
@ -14,9 +12,7 @@ class TransactionDatatable < AjaxDatatablesRails::Base
def data
records.map do |record|
[
record.id, record.debtor.name, record.creditor.name, record.amount
]
[ record.id, record.debtor.name, record.creditor.name, record.amount ]
end
end

View file

@ -10,9 +10,9 @@
:javascript
$(document).ready(function() {
$('#transactions').DataTable({
processing: true,
serverSide: true,
ajaxSource: $('#transactions').data('source'),
pagingType: 'full_numbers'
'processing': true,
'serverSide': true,
'ajax': $('#transactions').data('source'),
'pagingType': 'full_numbers'
});
});