How to show empty data message in Datatables

前端 未结 7 1434
感动是毒
感动是毒 2020-12-07 20:04

Suppose i get empty data from server sometimes, i want to display No Data found message in DataTables?. How is this possible?

7条回答
  •  北海茫月
    2020-12-07 20:17

    Late to the game, but you can also use a localisation file

    DataTable provides a .json localized file, which contains the key sEmptyTable and the corresponding localized message.

    For example, just download the localized json file on the above link, then initialize your Datatable like that :

    $('#example').dataTable( {
        "language": {
            "url": "path/to/your/json/file.json"
        }
    });
    

    IMHO, that's a lot cleaner, because your localized content is located in an external file.

    This syntax works for DataTables 1.10.16, I didn't test on previous versions.

提交回复
热议问题