Quantcast
Channel: Recent Discussions — DataTables forums
Viewing all articles
Browse latest Browse all 82233

Data Table Error

$
0
0
I use data table to display data from database and using ajax
but the datatable work good if we have less than 542 records


//fill CustomerData Table with Data

//Get CustomerData By WebService And Call Render Table To Push it
 
function GetCustomerTable() {
    $.ajax({
        type: "GET",
        url: "../WS_AddCustomer.asmx/CustomerData",
        data: { Type: "'" + $("#ctl00_cp_hd_Type").val() + "'" }, //show retweets
        cache: false,
        contentType: "application/json; charset=utf-8",
        dataType: "json",
        async: true,
        success: function (response) {
            //Calling Render
            alert(response.d);
            renderTable(response.d);
            $("#myGrid_Customer").dataTable().fnDestroy();    // destroy the old datatable
        },
        failure: function (errMsg) {
            ShowMsg('2', errMsg);
            $('#errorMessage').text(errMsg);
            //errorMessage is id of the div
        }
    });
}

//RenderTable(Customer ) Puch Data
function renderTable(result) {
    var dtData = [];
    $.each(result, function () {
        dtData.push([
                           this.Serial, this.Name, this.Tel, this.Details, this.Delete
                            ]);
    });
    alert(dtData);
    intialtize_Grid(dtData);
}

// create Customer grid (parent grid)
function intialtize_Grid(dtData) {
    $('#myGrid_Customer').dataTable({
        'aaData': dtData,
        'bPaginate': true,
        'bInfo': false, 'bDestroy': true,
        'bFilter': true,
        'bLengthChange': true,
        "aoColumns": [
            		{ "bSortable": true, sWidth: '80px' }, { sWidth: '80px' }, { sWidth: '80px' }, { sWidth: '80px' },
                     { sWidth: '80px' }
            		        ],
        'sPaginationType': 'full_numbers',
        'iDisplayLength': 5,
        "fnDrawCallback": function () {
            if ($("#myGrid_Customer").find("tr:not(.ui-widget-header)").length <= 5) {
                $('div.dataTables_paginate')[0].style.display = "none";
            } else {
                $('div.dataTables_paginate')[0].style.display = "block";
            }
            alert(this.fnPagingInfo().iPage);
        }

    });
}

Viewing all articles
Browse latest Browse all 82233

Trending Articles