Datatables.net ajax重装加载消息 [英] Datatables.net ajax reload loading message

查看:65
本文介绍了Datatables.net ajax重装加载消息的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在通过ajax初始加载我的数据表时,该表显示没有数据,并且表格主体中出现正在加载...。

On initial load of my datatable via ajax, the table shows no data and 'Loading...' appears in the table body.

在DataTable()上。 ajax.reload(),'Loading ...'文本不存在。

On DataTable().ajax.reload(), the 'Loading...' text is not present.

我知道我可以启用处理选项来获取表格中的栏,但如果我这样做,那么在初始加载时我的用户会看到表格正文中的正在加载...和处理...。

I know I can turn on the processing option to get the bar across the table, but if I do this then on initial loading my users see both 'Loading...' in the table body and 'Processing...' on top of that.

有没有人找到一个解决方案,一直有一个?对于每次ajax重新加载,我宁愿用'Loading ...'替换表体。

Has anyone found a solution to have one all the time or the other? I would prefer to replace the table body with 'Loading...' for each ajax reload.

谢谢!

推荐答案

使用Datatables 1.10我遇到了同样的问题。
我找到了一种方法让它发挥作用。
如果您使用在 ajax电话之前触发的preXhr事件,您可以

With Datatables 1.10 I had the same issue. I found a way to get this to work. If you use the preXhr event which fires before the ajax call you can


  1. 清除表格

  2. 将抽奖计数设置回0,再次触发
    初始消息

  3. 重新绘制表格并显示加载。

  1. clear the table
  2. Set the draw count back to 0, which triggers the initial message again
  3. ReDraw the table and loading will appear.

mydataTable.on('preXhr.dt', function(e, settings, data){
    $(this).dataTable().api().clear();
    settings.iDraw = 0;   //set to 0, which means "initial draw" which with a clear table will show "loading..." again.
    $(this).dataTable().api().draw();
});


这篇关于Datatables.net ajax重装加载消息的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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