jquery-datatables-rails
jquery-datatables-rails copied to clipboard
reload dataTable with previous settings
In my coffescript files:
table = $("#order_items").dataTable(
sDom: "<'row-fluid'r>t"
bProcessing: true
sScrollX: "100%"
bScrollCollapse: true
bAutoWidth: false
iDisplayLength: 25
aaSorting: [[1, "desc"]]
aoColumns: [
sWidth: "150px"
,
sWidth: "400px"
,
sWidth: "40px"
,
sWidth: "50px"
,
sWidth: "100px",
,
sWidth: "100px"]
bServerSide: true
oLanguage:
sUrl: $('#order_items').data('datatable')
sAjaxSource: $('#order_items').data('source')
aoColumnDefs: [
bSortable: false
aTargets: ["unsortable"]
]).fnSetFilteringDelay()
I create a file update.js.erb
and try the next:
table.ajax.reload();
When I try to run update.js.erb
, I lose the previous settings. I would like recovery the previous settings to show dataTable
with the same appearance, no search box, no counter, no pagination...etc
Thank you
I would try updating your initialization to the new API:
table = $("#order_items").DataTable
dom: "<'row-fluid'r>t"
processing: true
scrollX: "100%"
scrollCollapse: true
autoWidth: false
pageLength: 25
order: [ 1, 'desc' ]
columns: [
{ 'width': '150px' }
{ 'width': '400px' }
{ 'width': '40px' }
{ 'width': '50px' }
{ 'width': '100px' }
{ 'width': '100px' }
]
serverSide: true
language:
url: $('#order_items').data('datatable')
ajax:
url: $('#order_items').data('source')
pagingType: 'full_numbers'
columnDefs:
targets: 'unsortable'
sortable: false
searchDelay: 350 # <- search throttling replacement for fnSetFilteringDelay()
With new api dataTable is not reloaded, Thank you
Try $("#order_items").DataTable().ajax.reload()
for your reload code in update.js.erb
I checked this option and load dataTable with default settings again. Thank you!
Awesome, no problem.
Hi @hyperrjas, this thread can be closed?
No please, I have not yet managed to solve the problem. Thank you
What's the problem you're still having?