gpt4 book ai didi

如果没有数据,jQuery 数据表不显示表

转载 作者:行者123 更新时间:2023-12-03 22:37:08 26 4
gpt4 key购买 nike

我使用jquery数据表与服务器端获取数据,我的问题是当数据表为空时数据表隐藏表并且不显示,我想显示表消息上没有任何数据的表,如何有这个选项?

oTable_topics =$('#showTopics').dataTable({
"bLengthChange": false,
"bStateSave": true,
"iDisplayLength": 12,
"bScrollCollapse": true,
"bJQueryUI": true,
"bAutoWidth": false,
"sAjaxSource": "server_processing.php",
"sPaginationType": "full_numbers",
"bProcessing": true,
// "fnCreatedRow": function( nRow, aData, iDataIndex ) {
// $('td:eq(5)', nRow).html("<ul class='styledlist' style='width:80px !important;'><img src='http://localhost/shirazee/UI/images/icons/publish.png' style='border:none;'/></ul>");
// },
"fnDrawCallback": function(oSettings) {
clickRowHandler_topics();
if ( oSettings.aiDisplay.length == 0 )
{
return;
}
var nTrs = $('tbody tr', oSettings.nTable);
var iColspan = nTrs[0].getElementsByTagName('td').length;
var sLastGroup = "";
for ( var i=0 ; i<nTrs.length ; i++ )
{
var iDisplayIndex = oSettings._iDisplayStart + i;
var sGroup = oSettings.aoData[ oSettings.aiDisplay[iDisplayIndex] ]._aData[0];
if ( sGroup != sLastGroup )
{
var nGroup = document.createElement( 'tr' );
var nCell = document.createElement( 'td' );
nCell.colSpan = iColspan;
nCell.className = "group";
nCell.innerHTML = sGroup;
nGroup.appendChild( nCell );
nTrs[i].parentNode.insertBefore( nGroup, nTrs[i] );
sLastGroup = sGroup;
}
}
},
"aoColumnDefs": [
{ "bVisible": false, "aTargets": [ 0 ] }
],
"aaSortingFixed": [[ 0, 'asc' ]],
"aaSorting": [[ 1, 'asc' ]],
"fnServerParams": function ( aoData ) {
aoData.push(
{"name": "id" , "value": "i.id" },
{"name": "subject" , "value": "i.subject" },
{"name": "date_time", "value": "i.date_time"} ,
{"name": "posted_by", "value": "u.username"} ,
{"name": "ctitle" , "value": "c.title"} ,
{"name": "etitle" , "value": "e.title"},
{"name": "istatus" , "value": "i.status"},
{"name": "join" , "value": "JOIN categories c ON i.category = c.id JOIN status_topics e ON i.status = e.id JOIN users u ON i.posted_by = c.id"},
{"name": "action" , "value": "topics" }
)}
});
function clickRowHandler_topics() {
$('#showTopics tbody tr').bind('click', function () {
var aData = oTable_topics.fnGetData( this );
iId_topics = aData[1];
});
}

最佳答案

要根据结果数量切换表格可见性,只需使用属性fnDrawCallback:

var _grid = $("#myTable").dataTable({
fnDrawCallback: function (settings) {
$("#myTable").parent().toggle(settings.fnRecordsDisplay() > 0);
}
});

关于如果没有数据,jQuery 数据表不显示表,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/16779132/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com