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 class TransactionsController < ApplicationController
def index def index
p params
respond_to do |format| respond_to do |format|
format.html format.html
format.json { render json: TransactionDatatable.new(view_context) } format.json { render json: TransactionDatatable.new(view_context) }

View file

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

View file

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