jQuery DataTable with Server-Side processing using .NET Core 2.2

jQuery DataTable with Server-Side processing using .NET Core 2.2

DavidSuescunPelegayDavidSuescunPelegay Posts: 8Questions: 0Answers: 0

Hi, I've just created a simple Visual Studio solution using jQuery DataTable with Server-Side processing using .NET Core 2.2 (SDK: 2.2.202).

Check it out: https://github.com/DavidSuescunPelegay/jQuery-datatable-server-side-net-core

Replies

  • allanallan Posts: 61,439Questions: 1Answers: 10,053 Site admin

    Thanks very much for this! I've added a link to it from the DataTables news feed on the home page.

    Allan

  • DavidSuescunPelegayDavidSuescunPelegay Posts: 8Questions: 0Answers: 0

    Thank you very much allan

  • OSCAR VASQUEZOSCAR VASQUEZ Posts: 1Questions: 0Answers: 0

    Hello what I do not know, is how to place icons or buttons in the columns, to delete and edit record by record, please can you tell me how ...?

  • colincolin Posts: 15,112Questions: 1Answers: 2,583

    @OSCAR VASQUEZ ,

    Is this what you're after? If not, this doesn't seem related to the OP, so please could you create a new thread.

    Cheers,

    Colin

  • Bryan_ClaussBryan_Clauss Posts: 6Questions: 2Answers: 0

    @DavidSuescunPelegay,
    I'm using your jQuery project as the basis for a project that I'm working on.

    I've got the table showing in my browser correctly, except that during the LoadTable call (either from the page load or clicking on the columns) from the C# always shows the DTParameters parameter as NULL:

            [HttpPost]
            public async Task<IActionResult> LoadTable([FromBody]DTParameters dtParameters)
            {
    

    And this is my call out from the app.js script:

       $('#grade_list').DataTable(
            {
                // Design Assets
                stateSave: true,
                autoWidth: true,
                // ServerSide Setups
                processing: true,
                serverSide: true,
                // Paging Setups
                paging: true,
                // Searching Setups
                searching: { regex: true },
                // Ajax Filter
                ajax: {
                    url: "FinalGrade/LoadTable",
                    type: "POST",
                    contentType: "application/json",
                    dataType: "json",
                    data: function (d) {
                        return JSON.stringify(d);
                    }
                },
    

    I believe I've implemented everything correctly. Do you have any idea where to look to see why the DTParameters object would be null in the code-behind?

    This is my first DataTable project and I'm not sure where to look.

    Thanks for the demo project and hope to hear soon.

    -Bryan Clauss

  • allanallan Posts: 61,439Questions: 1Answers: 10,053 Site admin

    First thing I'd do myself is to check in the browser's Network inspector for the page to see that the data is indeed being sent as a POST with a JSON body. It looks like it should be from the above, but that's where to start.

    If it is there, then its a server-side configuration issue, and I'm less certain where to go there...!

    Allan

  • Bryan_ClaussBryan_Clauss Posts: 6Questions: 2Answers: 0

    @allan
    Thanks for the reply!

    I was using Chromes Developer Tools. I found where in the jQuery.js the json object is getting populated and posted (it looks correct there). I also see the json object in the Request Payload section of the Network tab.

    I'm just not sure why my C#/.NET code-behind is not seeing it.

    Unfortunately there doesn't seem to be a lot of .NET examples on the website and I'm kind of lost here. I'm checking the web for the C# side to see if I missed something.

    -Bryan

  • watch4sharxwatch4sharx Posts: 1Questions: 0Answers: 0

    @Bryan_Clauss

    Not sure if you're still having this issue, but I had the same problem integrating some of the code from the solution above into my .NET Core 3.0 web app. Worked fine in 2.2, but not 3.0. I spent hours working on it and it turns out it was that the DTParameters object was not being deserialized properly from the JSON data. I copied the payload being sent to the controller and did a paste special > class from JSON and then changed the controller to accept that new object and it worked.

  • DavidSuescunPelegayDavidSuescunPelegay Posts: 8Questions: 0Answers: 0

    Hi everyone, I'm currently working in a new version based on .NET Core 3, I'll push it in a few days.

    I'll also check all the issues you've send to me.

    Yesterday I uploaded a new version of .NET Core 2.2, you can check it out here:
    https://github.com/DavidSuescunPelegay/jQuery-datatable-server-side-net-core

    Please, stay tuned.

  • DavidSuescunPelegayDavidSuescunPelegay Posts: 8Questions: 0Answers: 0

    Hi @watch4sharx I've pushed a new release with support to .NET Core 3.0.

    Check it out here: https://github.com/DavidSuescunPelegay/jQuery-datatable-server-side-net-core

  • allanallan Posts: 61,439Questions: 1Answers: 10,053 Site admin

    Excellent - thank you for letting us know and maintaining your package :).

    Allan

  • plantplant Posts: 1Questions: 0Answers: 0

    @DavidSuescunPelegay

    I'm using your new release with support to .NET Core 3.0 but still getting the same problem as mentioned above DTParameters object null.

    Can anyone help me.

  • DavidSuescunPelegayDavidSuescunPelegay Posts: 8Questions: 0Answers: 0

    Hi @allan I've just updated my project adding .NET 5 support and Swagger Docs.

    https://github.com/DavidSuescunPelegay/jQuery-datatable-server-side-net-core

  • allanallan Posts: 61,439Questions: 1Answers: 10,053 Site admin

    That's awesome - thank you. I've posted it up on the front page links again :).

    Allan

  • DavidSuescunPelegayDavidSuescunPelegay Posts: 8Questions: 0Answers: 0

    Hi @allan I've just updated my project adding .NET 6 support

    https://github.com/DavidSuescunPelegay/jQuery-datatable-server-side-net-core

  • colincolin Posts: 15,112Questions: 1Answers: 2,583

    Nice, thanks for posting,

    Colin

  • mzandmzand Posts: 2Questions: 0Answers: 0
    edited July 2022

    For anyone interested: I have developed a simple but more generalized solution for server side paging, sorting and filtering in .Net 6. The sample I have provided in video series is based on the jQuery datatables
    https://datatables.net/forums/discussion/73505/for-net-developers-using-datatables-with-net-6

Sign In or Register to comment.