Click here to Skip to main content
15,886,873 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I have used jquery.Datatable for HTML pagination,but it always showing me no records in table..

JavaScript
 $("#btnSearch").live("click", function () {

     AJAXCall("POST", "../service/ClassRoom_Training.asmx/GetSubsidiaryBatchList", false, '{"DomainId":"' + DomainId + '","fDate":"' + fDate + '","tDate":"' + tDate + '","TrainingName":"' + TrainingName + '","BatchId":"' + BatchId + '","LevelId":"' + LevelId + '","CountryId":"' + CountryId + '","LanguageId":"' + LanguageId + '","CityId":"' + CityId + '" }', "application/json; charset=utf-8", "json", GetSusidiaryList);

                
                checkpaging();
          
          return false;
    });
function GetSusidiaryList(response) {
 var tblID = '';
    var tbl = response.d;
    var Data = response.d;
    var ControlID = "divSubsidiary";
    if (Data != null) {
        if (Data != "ERROR") {
            if (Data.indexOf('♠') > -1) {
                var Data1 = Data.split('♠');
                tbl = Data1[0];
                tblID = Data1[1];
            }

            $('#' + ControlID).html(tbl);
            if (Data.indexOf('♠') > -1) {
                $('#btnDownload').toggle();
                $('#' + tblID).dataTable({
                    "sPaginationType": "full_numbers",
                    "bDestroy": true,
                    "bRetrieve": true
                });
            }
        }
        else {
            RedirectToLogin();
        }

    }
    else {
        RedirectToLogin();
        
    }

}



But it always display Showing 0 to 0 out of 0 entries and No records in table.
I tried all possible ways but not able to solve.
Please help me ..its very urgent
Posted

1 solution

Consider for example:
HTML
<table id="example">
     <thead>
    <th>Column 1</th>
    <th>Column 2</th>
    <th>Column 3</th>
    <th>Column 4</th>
    </thead>
</table>

Applying $('#example').dataTable({  "sPaginationType": "full_numbers"});

will show No data available in table
Showing 0 to 0 of 0 entries

If you have the data from the webservice, then simply append the data by forming exact string of tr's & td's and append like
$("#example").append('<tr><td>Data</td><td>Data</td></tr>');

and then apply
$('#example').dataTable({  "sPaginationType": "full_numbers"});
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900