vendredi 22 juillet 2016

how to fire table's load event in jquery

I have a table with class named "mygrid ".

I want table load event so that if table is blank i can add a tr with "No records".

  $(document).ready(function () {
                hideActivePapers();
     });   


  <script type="text/javascript">
            function hideActivePapers() {              
                $('table.mygrid').load(function () {
                    var rowCount = $('.mygrid tr.ng-valid').length;
                    alert(rowCount);
                    if (rowCount == 0) {
                        $('.mygrid').find('tbody').append('<tr class="norecords"> <td colspan="11" style="margin-left:5px;" >No Records</td></tr>');
                    }
                    else {
                        $('tr.norecords').remove();
                    }
                });
            }
        </script>

Aucun commentaire:

Enregistrer un commentaire