How to speed up loading nearly 30 thousand records?

How to speed up loading nearly 30 thousand records?

mcemce Posts: 6Questions: 1Answers: 0
edited March 2023 in Free community support

Hello all,

I am going to load a lot of records via my c# programs GridView control - but it takes about 1 minute before all data has been rendered using DataTables.net.
So therefore I will ask about the following: Can I (maybe via a ajax call) load fewer records at a time via pagination - so if I choose to show 50 records at each page, then I only need to fill in 50 records to my GridView control?
Is that possible - or is there another method?

Best regards,
Michael

Answers

  • kthorngrenkthorngren Posts: 21,342Questions: 26Answers: 4,954
    edited March 2023

    Datatables has Server Side Processing to support server based paging. Your server script will need to support the SSP Protocol. Not sure if your environment will with with any of the Editor libraries. If so this blog shows how to use them for SSP.

    Kevin

  • mcemce Posts: 6Questions: 1Answers: 0
    edited March 2023

    Thanks for answering :smile:

    But should I create a WebMethod in C# and return a DataSet to the ajax call? And in which way can I find out a start record to show and how many records I have to return - in according to pagination? Is it variables I can read and transfer to the WebMethod?

    Thanks for an example - :smile:

    Thanks in advance.

  • kthorngrenkthorngren Posts: 21,342Questions: 26Answers: 4,954
    edited March 2023

    But should I create a WebMethod in C# and return a DataSet to the ajax call?

    Yes.

    can I find out a start record to show and how many records I have to return

    The SSP Protocol docs explain the paging, search and sort values sent to the server and what is required in the response. Let us know if you have any questions about the protocol.

    Here are some live examples:
    https://datatables.net/examples/server_side/index.html

    Kevin

  • mcemce Posts: 6Questions: 1Answers: 0
    edited March 2023

    Hello again ...
    I can see some Sent parameters - but where do I need to fill in "start" and "length" - and which variables contain the current values to start and lenght - so I can increment/decrement them? Is it something like:

        ajax: {
            url: '/data-source',
            type: 'POST'
            start: <value>
            length: <value>
        }
    

    Thanks in advance.
    Michael

  • kthorngrenkthorngren Posts: 21,342Questions: 26Answers: 4,954

    When you enable the serverSide processing option, by setting it true, Datatables will automatically send those parameters.

    Kevin

  • mcemce Posts: 6Questions: 1Answers: 0
    edited March 2023

    Thank you very much :smile:
    But when I normally create a webmethod in C# - I need to create some parameters too, so I can transfer values from Javascript to C# - but is it possible for assistance to how I can create a C# webmethod for connecting with DataTables? Im wondering how I can read start and lenght in my C# Webmethod...

    Should the Webmethod look something like this:

    public static DataSet GetDataset(int start, int length)
    {
    }
    
  • kthorngrenkthorngren Posts: 21,342Questions: 26Answers: 4,954

    Im wondering how I can read start and lenght in my C# Webmethod...

    Sorry I don't know anything about C# Webmethod. Maybe the developer Allan does. However Datatables just sends standard Ajax requests to the server. Maybe this SO thread or others will help you to read the parameters sent.

    I need to create some parameters too, so I can transfer values from Javascript to C#

    This example shows how to add additional parameters to send to the server.

    Kevin

  • mcemce Posts: 6Questions: 1Answers: 0
    edited March 2023

    Thank you very much - I will take a look at SO too ...

  • mcemce Posts: 6Questions: 1Answers: 0

    Thanks for your assistance too :smile:

Sign In or Register to comment.