if ($('input[name="expense_account"]').length > 0) { $.getJSON('json/expense-accounts').success(function (data) { $('input[name="expense_account"]').typeahead({source: data}); }); } if ($('input[name="revenue_account"]').length > 0) { $.getJSON('json/revenue-accounts').success(function (data) { $('input[name="revenue_account"]').typeahead({source: data}); }); } if ($('input[name="category"]').length > 0) { $.getJSON('json/categories').success(function (data) { $('input[name="category"]').typeahead({source: data}); }); } $(document).ready(function () { $('#transactionTable').DataTable( { serverSide: true, ajax: URL, paging: true, processing: true, order: [], "lengthMenu": [[50, 100, 250, -1], [50, 100, 250, "All"]], columns: [ { name: 'date', data: 'date', searchable: false }, { name: 'description', data: 'description', render: function (data, type, full, meta) { var icon = ''; if (display == 'expenses') { icon = 'glyphicon-arrow-left'; } if (display == 'revenue') { icon = 'glyphicon-arrow-right'; } if (display == 'transfers') { icon = 'glyphicon-resize-full'; } return ' ' + '' + data.description + ''; } }, { name: 'amount', data: 'amount', searchable: false, render: function (data, type, full, meta) { if (display == 'expenses') { return '\u20AC ' + data.toFixed(2) + ''; } if (display == 'revenue') { return '\u20AC ' + data.toFixed(2) + ''; } if (display == 'transfers') { return '\u20AC ' + data.toFixed(2) + ''; } } }, { name: 'from', data: 'from', searchable: false, render: function (data, type, full, meta) { return '' + data.name + ''; } }, { name: 'to', data: 'to', searchable: false, render: function (data, type, full, meta) { return '' + data.name + ''; } }, { name: 'id', data: 'id', searchable: false, render: function (data, type, full, meta) { return '
'; } } ] } ); });