javascript - Hide "No data available in table" message when data is present -
this table , data list using json , populate table,
<table id="tblclaimsearch" class="display responsive nowrap" cellspacing="0" width="100%"> <thead> <tr> <th><input type="checkbox" id="chkboxclaimheader" name="chkboxclaimheader" value="false"></th> <th>claim #</th> <th>client name</th> <th>amount</th> <th>deduction</th> <th>type</th> <th>status</th> </tr> </thead> <tbody> </tbody> </table>
my jquery has json result, result , append rows table body based on data,
$(document).ready(function () { $.ajax({ url: '@url.action("claimresulttest", "claims")', data: { seacrhclaimnumber: claimnumbertobesearched }, type: 'post', success: function (data) { var dataclaims = data.claims;//this has complete list (i = 0; < dataclaims.length; i++) { alert(dataclaims[i].claimnumber); $("#tblclaimsearch").find('tbody') .append($('<tr>') .append($('<td><input type="checkbox">')) .append($('<td>').text(dataclaims[i].claimnumber)) .append($('<td>').text(dataclaims[i].client)) .append($('<td>').text(dataclaims[i].amount)) .append($('<td>').text(dataclaims[i].deduction)) .append($('<td>').text(dataclaims[i].type)) .append($('<td>').text(dataclaims[i].status)) ) } } }); });
the problem when there no data, have row displaying "no data available in table"..and when there data appended still have first row "no data available in table"..how hide message row when new rows data have been added??and secondly though have 16 entries still shows "showing 0 of 0 entries"?.what doing wrong?..
try this:-
$(document).ready(function () { $.ajax({ url: '@url.action("claimresulttest", "claims")', data: { seacrhclaimnumber: claimnumbertobesearched }, type: 'post', success: function (data) { $("#tblclaimsearch").find('tbody').empty(); //add line var dataclaims = data.claims;//this has complete list (i = 0; < dataclaims.length; i++) { alert(dataclaims[i].claimnumber); $("#tblclaimsearch").find('tbody') .append($('<tr>') .append($('<td><input type="checkbox">')) .append($('<td>').text(dataclaims[i].claimnumber)) .append($('<td>').text(dataclaims[i].client)) .append($('<td>').text(dataclaims[i].amount)) .append($('<td>').text(dataclaims[i].deduction)) .append($('<td>').text(dataclaims[i].type)) .append($('<td>').text(dataclaims[i].status)) ) } } }); });
Comments
Post a Comment