使用数据表加载消息 [英] Loading Message using Datatables

查看:49
本文介绍了使用数据表加载消息的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我将Datatables与PHP和Mongo结合使用来制作CRUD.

Im using Datatables with PHP and Mongo to make a CRUD.

这是我的代码,可以正常工作

This is my Code and it works fine

table = $('#example').DataTable({
    "bLengthChange": false,
    "ajax": "./get_clients"
});

这是我加载新数据的功能,它可以正常工作:

This is my function to load new data and it works fine:

table.ajax.reload();

当我加载页面时,我收到一条正在加载..."消息,但是当我使用"table.ajax.reload()"重新加载时,却没有看到正在加载..."消息,这很烦人,原因是我的用户可能不知道网格正在加载.

When I load the page I get a "Loading..." message, but when I reload with "table.ajax.reload()", I get no "Loading..." message which is annoying cause my users might not know the grid is loading.

我可以将此行添加到我的数据表参数中:

I can add this line to my datatable params:

"processing": true,

这会给我一条带有不同CSS样式的正在处理..."消息.

And that would give me a "Processing..." Message with a different CSS style.

我想知道是否有办法在仍然使用我的重新加载ajax代码的同时,将其所有属性都显示为正在加载..."消息.

I'd like to know if there is a way to have the "Loading..." message with all of its properties while still using my reload ajax code.

我正在使用版本数据表1.10.10

Im' using version Data tables 1.10.10

推荐答案

不是. 正在加载..."消息是在初始化过程中添加的实际表行,而正在处理..."消息是叠加层.

Not really. The "Loading..." message is an actual table row that is added during initialisation, whereas the "Processing..." message is an overlay.

我建议使用语言功能将正在加载..."消息保留为空白,而只需使用叠加层即可:

I suggest using the language feature to blank the "Loading..." message and just use the overlay:

$(document).ready( function () {
  var table = $('#example').DataTable( {
    ajax: '/ajax/arrays.txt',
    processing: true,
    'language':{ 
       "loadingRecords": " ",
       "processing": "Loading..."
    }
  } );

  $('#reload').click( function () {
    table.ajax.reload();
  } );

} );

您当然不能使用 并将loadingRecords设置为空字符串,但是初始表行的高度将在没有该位置的情况下折叠.

You could of course not use   and set loadingRecords to an empty string, but that initial table row's height will collapse somewhat without.

示例: http://live.datatables.net/cepunoyi/1/edit

这篇关于使用数据表加载消息的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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