为什么dataTable不显示空数据消息? [英] Why does dataTable doesnt show empty data message?

查看:509
本文介绍了为什么dataTable不显示空数据消息?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

当我在dataTable服务器端处理中找不到特定搜索的结果时,这就是我返回数据集的方式

This is how i return my dataset when no results found for particular search in dataTable serverside processing

data :null
recordsFiltered:"0"
recordsTotal:"0"

但是frondend没有显示任何没有结果发现消息。坚持处理。和控制台给出错误

but frondend doesnt show any no result found message .its stuck with processing. and console give an error

Uncaught TypeError: Cannot read property 'length' of null

也许这是null意味着我的数据= null。

maybe this is null means my data=null.

如何显示数据表默认值消息说没有搜索结果。 ?我正在使用数据表版本1.10.13与服务器端处理,请建议

how can I show datatable default message saying no search results. ? i'm using datatable version 1.10.13 with serverside processing , pls advice

推荐答案

您需要在<$ c中返回空数组$ c> data 属性,请参阅下面的示例JSON响应:

You need to return empty array in data property, see sample JSON response below:

{
    "draw": 1,
    "recordsFiltered": 0,
    "recordsTotal": 0,
    "data": []
}

这篇关于为什么dataTable不显示空数据消息?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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