Make transaction datatable actually work
This commit is contained in:
parent
c3c13f428a
commit
20bb280482
3 changed files with 7 additions and 10 deletions
|
@ -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) }
|
||||||
|
|
|
@ -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
|
||||||
|
|
||||||
|
|
|
@ -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'
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
Loading…
Reference in a new issue