数据表:插入一条数据时样式变粗 [英] datatables: style becomes bold when inserting a piece of data

查看:291
本文介绍了数据表:插入一条数据时样式变粗的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

通过ajax方式设置数据表,每隔几秒自动从数据库刷新数据,当空表加入数据表样式变得特别厚,f5后样式可以恢复正常。

Set datatables through ajax way every few seconds to automatically refresh from the database to read data, when the empty table to join a data table style becomes particularly thick, f5 after the style can return to normal.

自动刷新数据表代码:

function autoRefresh() {
$('#demo').DataTable().draw(false);
t = setTimeout('autoRefresh()', 5 * 1000);
}

此代码我尝试过同样的问题:

This code I have tried the same problem:

setInterval( function () {
table.ajax.reload( null, false ); // user paging is not reset on reload
}, 5 * 1000 );

谢谢!

推荐答案

我相信问题在于,您正在使用新数据集在上表之上绘制一个新表。在文档中,它解释了ajax.reload()函数,该示例正在以不同的方式进行初始化。假设您正在通过JSON对象加载数据,我建议这样做,而不是重新绘制表格。

I believe the problem is that you are drawing a new table on top of the previous table with the new dataset. In the documentation, where it explains the ajax.reload() function, the example is table is being initialized differently. Assuming that you are loading data in via a JSON object, I would suggest doing it that way rather than redrawing the table..

var table = $('#demo').DataTable({
    ajax: "data.json"
});

setInterval( function () {
    table.ajax.reload( null, false ); // user paging is not reset on reload
}, 30000 );

这篇关于数据表:插入一条数据时样式变粗的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆