jQuery DataTable 自定义语言 url 有效,但加载程序无效
jQuery DataTable custom language url works, but loader doesn't
是否可以在 jQuery dataTable
中添加具有自定义语言 url 的加载程序?
例如:
"language":
{
"processing": "<span style="width:100%;"><img src="http://www.snacklocal.com/images/ajaxload.gif"></span>",
"url": "http://cdn.datatables.net/plug-ins/9dcbecd42ad/i18n/German.json"
}
当我同时拥有两者时它不起作用,但如果我评论 url 行,加载器工作。
尝试一下;
"language":
{
"processing": "<span style='width:100%;'><img src='http://www.snacklocal.com/images/ajaxload.gif'></span>",
"url": "http://cdn.datatables.net/plug-ins/9dcbecd42ad/i18n/German.json"
}
这里是使用 ES6 template literals
的解决方案
"language":
{
"processing": `<span style="width:100%;"><img src="http://www.snacklocal.com/images/ajaxload.gif"></span>`,
"url": "http://cdn.datatables.net/plug-ins/9dcbecd42ad/i18n/German.json"
}
希望对您有所帮助。
我发表了 this 篇文章,我给 DataTable 论坛发了消息,他们很伤心:
This is something that is going to be added in for v2 of DataTables, which is in progress, but slowly.
Until then you would need to load the Ajax language information using $.getJSON (or similar) and then merge it into your local object as needed, then using the result in the DataTable configuration
更新:
我评论我的源代码行并手动添加文本,如下所示:
"language": {
// "sUrl": "../HTMLRepository/JsLocalization/DataTableLocalization_Serbian.json"
"sEmptyTable": "Ni jedan podatak ne postoji za zadate kriterijume",
"sInfo": "Prikaz _START_ do _END_ od ukupno _TOTAL_ redova po strani",
"sInfoEmpty": "Prikaz 0 do 0 od ukupno 0 redova",
"sInfoFiltered": "(filtrirano od ukupno _MAX_ redova)",
"sInfoPostFix": "",
"sInfoThousands": ",",
"sLengthMenu": "Prikaz _MENU_ redova",
"sLoadingRecords": "Molimo sačekajte, učitavanje u toku...",
"sSearch": "Pretraži:",
"sZeroRecords": "Podaci se ne podudaraju",
"oPaginate": {
"sFirst": "Prva",
"sLast": "Poslednja",
"sNext": "Sledeća",
"sPrevious": "Predhodna"
}
},
并且在 $(document).ready 函数中我有
$('#patientsTable').on('processing.dt', function (e, settings, processing) {
if (processing) {
activateLoader();
activateOverlay();
}
else {
deactivateLoader();
deactivateOverlay();
}
终于成功了:)
非常感谢@Shiladitya
是否可以在 jQuery dataTable
中添加具有自定义语言 url 的加载程序?
例如:
"language":
{
"processing": "<span style="width:100%;"><img src="http://www.snacklocal.com/images/ajaxload.gif"></span>",
"url": "http://cdn.datatables.net/plug-ins/9dcbecd42ad/i18n/German.json"
}
当我同时拥有两者时它不起作用,但如果我评论 url 行,加载器工作。
尝试一下;
"language":
{
"processing": "<span style='width:100%;'><img src='http://www.snacklocal.com/images/ajaxload.gif'></span>",
"url": "http://cdn.datatables.net/plug-ins/9dcbecd42ad/i18n/German.json"
}
这里是使用 ES6 template literals
"language":
{
"processing": `<span style="width:100%;"><img src="http://www.snacklocal.com/images/ajaxload.gif"></span>`,
"url": "http://cdn.datatables.net/plug-ins/9dcbecd42ad/i18n/German.json"
}
希望对您有所帮助。
我发表了 this 篇文章,我给 DataTable 论坛发了消息,他们很伤心:
This is something that is going to be added in for v2 of DataTables, which is in progress, but slowly.
Until then you would need to load the Ajax language information using $.getJSON (or similar) and then merge it into your local object as needed, then using the result in the DataTable configuration
更新: 我评论我的源代码行并手动添加文本,如下所示:
"language": {
// "sUrl": "../HTMLRepository/JsLocalization/DataTableLocalization_Serbian.json"
"sEmptyTable": "Ni jedan podatak ne postoji za zadate kriterijume",
"sInfo": "Prikaz _START_ do _END_ od ukupno _TOTAL_ redova po strani",
"sInfoEmpty": "Prikaz 0 do 0 od ukupno 0 redova",
"sInfoFiltered": "(filtrirano od ukupno _MAX_ redova)",
"sInfoPostFix": "",
"sInfoThousands": ",",
"sLengthMenu": "Prikaz _MENU_ redova",
"sLoadingRecords": "Molimo sačekajte, učitavanje u toku...",
"sSearch": "Pretraži:",
"sZeroRecords": "Podaci se ne podudaraju",
"oPaginate": {
"sFirst": "Prva",
"sLast": "Poslednja",
"sNext": "Sledeća",
"sPrevious": "Predhodna"
}
},
并且在 $(document).ready 函数中我有
$('#patientsTable').on('processing.dt', function (e, settings, processing) {
if (processing) {
activateLoader();
activateOverlay();
}
else {
deactivateLoader();
deactivateOverlay();
}
终于成功了:) 非常感谢@Shiladitya