<%= javascript_tag do %> $(document).ready(function() { var table = $('#accounts-table').DataTable({ "dom": "<'row'r>t<'row'<'col-md-6'i><'col-md-6'p>>", "pagingType": <% if @max_nb_records.nil? -%>"simple"<% else -%>"full_numbers"<% end -%>, "language": { "info": <% if @max_nb_records.nil? -%>"Showing _START_ to _END_ of <%= number_with_delimiter(Kaui::EngineControllerUtil::SIMPLE_PAGINATION_THRESHOLD) -%>+ entries"<% else -%>"Showing _START_ to _END_ of _TOTAL_ entries"<% end -%> }, "pageLength": <%= @limit %>, "displayStart": <%= @offset %>, <% unless @ordering.blank? %> "order": [[ 1, "<%= @ordering %>" ]], <% end %> "processing": true, "serverSide": true, "search": {"search": "<%= @search_query %>"}, "ajax": "<%= accounts_pagination_path(:ordering => @ordering, :format => :json) %>", "rowCallback": function( row, data, index ) { if ( data[0] == 1 ) { $('td:eq(0)', row).html( 'Child' ); }else{ $('td:eq(0)', row).html('') } }, "columnDefs": [ { "orderable": false, "targets": 0, "createdCell": function (td, cellData, rowData, row, col) { $(td).css('padding-left', '20px'); $(td).css('width', '60px'); } } ] }); <% if @max_nb_records.nil? %> $('#accounts-table').on('draw.dt', function() { var noMoreData = table.column(0) .data() .length == 0; $(".next.paginate_button").toggleClass("disabled", noMoreData); $(".dataTables_info").toggle(!noMoreData); }); <% end %> }); <% end %>