Dataset over 500 count results in no data and an error

Dataset over 500 count results in no data and an error

odomodom Posts: 4Questions: 1Answers: 0
edited December 2023 in Free community support

As the title says, I have a C# list of objects mocked up from an XML file, if I try to load everything I have about 6,500 objects in the list - however if I attempt to load this in the DataTable using a WebMethod, 500 seems to be the hard stop as it will not load or function beyond 500 objects.

JQuery on .aspx page:

                jQuery(document).ready(function () {
                            jQuery('#pricingDataTable').DataTable({
                                "ajax": {
                                    "url": "Pricing.aspx/GetPricingData",
                                    "type": "POST",
                                    "datatype": "json",
                                    "contentType": 'application/json; charset=utf-8',
                                    "dataSrc": function (json) {
                                        return json.d;
                                    }
                                },
                                "columns": [
                                    { "data": "Supplier" },
                                    { "data": "Category" },
                                    { "data": "StyleName" },
                                    { "data": "StyleNumber" },
                                    { "data": "SKU" },
                                    { "data": "Collection" }
                                ],
                                "language": {
                                    "lengthMenu": 'Items Per Page: <select>' +
                                        '<option value="10">10</option>' +
                                        '<option value="20">20</option>' +
                                        '<option value="30">30</option>' +
                                        '<option value="40">40</option>' +
                                        '<option value="50">50</option>' +
                                        '<option value="-1">All</option>' +
                                        '</select>',
                                    "info": 'Showing _START_ - _END_ of _TOTAL_ items found'
                                },
                                "searching": false
                            });
                        });

Web Method that loads data:

[WebMethod]
        public List<PricingDataGrid> GetPricingData()
        {
            var rugs = GetItems(rugFilePath).Take(250);
            var sheetVinylItems = GetItems(sheetVinylFilePath).Take(250);

            List<PricingDataGrid> data = new List<PricingDataGrid>();
            data.AddRange(rugs);
            data.AddRange(sheetVinylItems);

            return data;
        }

The error message I receive:

DataTables warning: table id=pricingDataTable - Ajax error. For more information about this error, please see https://datatables.net/tn/7

As you can see, for the proof of concept I have only taken 250 from each list so I do not exceed the 500 item limitation. I've searched the documentation for hours and cannot find any mention of a limit so there must be a setting I'm missing. I have also tried serializing this list into a JSON object and returning it, it still does not work. Any help or thoughts would be greatly appreciated!

Edited by Allan - Syntax highlighting. Details on how to highlight code using markdown can be found in this guide.

This question has an accepted answers - jump to answer

Answers

  • allanallan Posts: 63,498Questions: 1Answers: 10,471 Site admin

    If you follow the instructions at the linked tech note, what does the server actually respond with? It might contain an error message that indicates what is going wrong.

    Allan

  • odomodom Posts: 4Questions: 1Answers: 0

    I'm having issues modifying the post, I don't see an edit button anywhere - the formatting didn't work correctly for some reason and I forgot to put static on the method (it's a requirement of webmethod).

    Anyways, the tech note is all about ajax requests and how to debug a generic request, nothing is data specific and I have tried to change a couple of things but it just results in the same error message

  • odomodom Posts: 4Questions: 1Answers: 0

    To be more clear, the status I'm getting from the call is a 500, nothing in the webmethod is failing or throwing any errors, it's just refusing to accept a dataset larger than 500. I'm really at a loss here.

  • allanallan Posts: 63,498Questions: 1Answers: 10,471 Site admin
    Answer ✓

    I've edited your post for markdown now. We only allow editing for a short period of time after the original post, otherwise I'm likely to miss stuff that gets added / edited.

    What is the response from the server when you have more than 500 records please? If it is valid JSON DataTables would accept it, but the error suggests that it is not valid JSON, and that the server is throwing an error. Checking the response from the server is the first step. The instructions for that are in the tech note.

    If you can link to a page showing the issue that would be useful.

    Allan

  • odomodom Posts: 4Questions: 1Answers: 0

    Allan,
    I've double checked and I think you are right - I think the file is formatted incorrectly. Thank you for the help!

Sign In or Register to comment.