Datatable with webmethod not populating more than 500 rows

Datatable with webmethod not populating more than 500 rows

nidhinceenidhincee Posts: 2Questions: 1Answers: 0
edited November 2018 in Free community support

Hi,
I have a webmethod which returns data as json. There is more than 500 rows in that. But the datatable not poulating more than 100 rows. I will add my code below,

**Web Method**
 public static string TestBigData()
        {
            List<BACAServiceRequests> lstserviceReq = new List<BACAServiceRequests>();
            for (int i = 0; i <= 150; i++)
            {
                BACAServiceRequests cs = new BACAServiceRequests
                {
                    ID = i,
                    Request_x0020_No = "No" + i.ToString(),
                    Requested_x0020_By = "No" + i.ToString(),
                    Service_x0020_Title = "No" + i.ToString(),
                    Request_x0020_Assigned_x0020_To = "No" + i.ToString(),
                    Service_x0020_Category = "No" + i.ToString(),
                    Task_x0020_Status = "No" + i.ToString(),
                    Requested_x0020_Date = DateTime.Now,
                    KPI = 3,
                    Start_x0020_Date = DateTime.Now,
                    Expected_x0020_End_x0020_Date = DateTime.Now,
                    End_x0020_Date = DateTime.Now,
                    Conformity = "N/A",
                    Days = 2,
                    Notes = "solution",

                };
                lstserviceReq.Add(cs);
            }
            var jsonData2 = new
            {
                data = lstserviceReq.Select(item => new
                {
                    ID = item.ID.ToString() ,
                    RequestNo = item.Request_x0020_No.ToString() ,
                    RequestedBy = item.Requested_x0020_By.ToString() ,
                    Title = item.Service_x0020_Title.ToString() ,
                    AssignedTo = item.Request_x0020_Assigned_x0020_To != "" ,
                    RequestedService = item.Service_x0020_Category.ToString() != "" ,
                    RequestStatus = item.Task_x0020_Status.ToString() != "" ,
                    RequestDate = item.Requested_x0020_Date.ToString(),
                    KPI = item.KPI.ToString(),
                    StartDate = item.Start_x0020_Date.ToString(),
                    ExpectedEndDate = item.Expected_x0020_End_x0020_Date ,
                    EndDate = item.End_x0020_Date.ToString("dd/MM/yyyy hh:mm:ss tt", CultureInfo.InvariantCulture),
                    Conformity = "N/A",
                    TCDays = 3.ToString(),
                    Solution = item.Notes.ToString(),
                })
            };


            //  var jsonData2 = 
            return Newtonsoft.Json.JsonConvert.SerializeObject(jsonData2);
        }

Script

jqhdr(document).ready(function () {

 jqhdr.ajax({
            url: "/_layouts/15/Pages/WebMethods.aspx/TestBigData",
            type: "POST",
            dataType: "json",
            contentType: "application/json; charset=utf-8",
            async: false,
            success: function (json) {
                var dataSet = JSON.parse(json.d).data;

                jqhdr('#examble').DataTable({
                    destroy: true,
                    data: dataSet,
                    deferRender: false,
                    scrollY:        200,
                    scrollCollapse: true,
                    scroller:       true,
                    "columns": [
                    {
                        "data": "ID", "title": "ID", "visible": false

                    },
                    {
                        "data": "RequestNo", "title": "Request No"
                    },
                    { "data": "RequestedBy", "title": "Requested By" },
                   { "data": "Title", "title": "Title" },
                    { "data": "AssignedTo", "title": "Assigned To" },
                    { "data": "RequestedService", "title": "Requested Service" },
                   { "data": "RequestStatus", "title": "Request Status" },
                   { "data": "RequestDate", "title": "Request Date" },
                   { "data": "KPI", "title": "KPI" },
                   { "data": "StartDate", "title": "Start Date" },
                   { "data": "ExpectedEndDate", "title": "Expected End Date" },
                    { "data": "EndDate", "title": "End Date" },
                    { "data": "Conformity", "title": "Conformity" },
                    { "data": "TCDays", "title": "TCDays" },
                    { "data": "Solution", "title": "Solution" }
                    ]

                });
            }
        });

}

HTML

<div class="row">

    <table id="examble">
    </table>
   
</div>

I am new to DataTable.net, can anyone help please

Answers

  • nidhinceenidhincee Posts: 2Questions: 1Answers: 0

    Json data from webmethod contains all the 2000 rows but it is not getting populated in DataTable

  • colincolin Posts: 15,240Questions: 1Answers: 2,599

    Hi @nidhincee ,

    Does dataSet contain all 2000 rows? If so, that should work, the code looks OK.

    We're happy to take a look. As per the forum rules, if you could link to a running test case showing the issue we can offer some help. Information on how to create a test case (if you aren't able to link to the page you are working on) is available here.

    Cheers,

    Colin

This discussion has been closed.