简体   繁体   English

使用HTML(DOM)重新初始化DataTables,而不会丢失dom中的数据

[英]Reinitialise DataTables with HTML (DOM) sourced data without loosing the data in the dom

we have a rather complex structure and combination of technologies for generating a table at the end. 我们有一个相当复杂的结构和技术组合,最终生成一个表。

We have a custom binding ,in that custom binding I initialize the datatables with $('.DataTables').DataTable(); 我们有一个自定义绑定,在自定义绑定中,我用$('.DataTables').DataTable();初始化$('.DataTables').DataTable(); in the init (Knockout), this works fine if the data is already present. init (Knockout)中,如果数据已经存在,这可以正常工作。

But for the case, where the data will be loaded later ,because of an AJAX-Request, this does not work. 但是对于这种情况,由于AJAX-Request,数据将在稍后加载,这不起作用。

I need something to reinitialize the DataTable, with data which is present in the HTML(the data is already present in the html, but clicking on any column for sorting will make the data disappear). 我需要一些东西来重新初始化DataTable,HTML中存在数据(数据已经存在于html中,但点击任何列进行排序会使数据消失)。

What can I do ? 我能做什么 ?

Now 现在

Process to re initialize data table: 重新初始化数据表的过程:

$('#theID').DataTable().ajax.reload();

This will reinitialize datatable loading new data if any. 这将重新初始化数据表加载新数据(如果有)。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM