简体   繁体   中英

jQuery jTable: How to hide table headers when 0 records are returned from server

I simply want a message displayed on the page, with no table headers, if there are no records to display.

Is there a way to achieve this with jtable via an option, may be?

@oderayi I don't think so that there is an option in jTable api to hide table headers when you have 0 records from the database.

If I were you I would execute $("#myJTable .jtable-column-header).hide() on ajax success callback like this:

 $.ajax({ type: "GET", url: "YOUR_URL", data: { yourData: yourData }, success: function (data) { if(data.Records.length === 0) { $("#yourJTable .jtable-column-header").hide(); //No data available message $("#yourJTable tbody).append("<tr class='jtable-no-data-row'><td colspan='1'>No data available!</td></tr>"); } } }); 

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM