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

122 Views Asked by At

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?

1

There are 1 best solutions below

0
falwick falwick On

@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>");
           }
        }
    });