Giter Site home page Giter Site logo

davidsuescunpelegay / jquery-datatable-server-side-net-core Goto Github PK

View Code? Open in Web Editor NEW
125.0 125.0 32.0 3.91 MB

A simple Visual Studio solution using jQuery DataTable with Server-Side processing using .NET

License: MIT License

HTML 1.74% C# 13.58% CSS 25.52% JavaScript 59.16%
asp-net-core asp-net-core-mvc datatable datatables datatables-ajax datatables-plugin javascript jquery jquery-datatable jquery-datatable-serverside jquery-datatables jquery-plugin net-core net5 net6 netcore2 netcore3 netcore31 visual-studio

jquery-datatable-server-side-net-core's Introduction

👋 Hello, David here

💻 Full Stack Developer & Project Manager since 2017

📫 You can reach me at [email protected] or LinkedIn

🛠  Development environments

C#  .NET Core  Xamarin  Azure  Android  Docker  Kubernetes  Angular  Firebase  Ionic 

📈  Some of my GitHub stats

jquery-datatable-server-side-net-core's People

Contributors

alanlaitw avatar davidsuescunpelegay avatar fouadgm avatar sametcekin avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar

jquery-datatable-server-side-net-core's Issues

A thanks from young developer

Sir, I want to thank you for this public repository. I'm a very beginner (junior) backend developer and I'm trying to learn asp.net core mvc. Thanks to this pre-installed code I easily understand the Datatable mechanism. Thank you a lot...

Null reference in LoadTable method

Line 43 (dtparameters.Order reference) and 37 (dtParameters.Search reference) leave null references. Happy to do a PR and contribute if you'd like me to give a hand. Well done on setting 3.1 up.

Export All Rows Is Not Working

I have tried to export all rows but is exporting only displayed rows it would be very helpful if anyone can address this issue thanks.

Your getting the full recordset every time?

Not sure what the point of this demo is since your controller is getting the full 1000 records each time and you are then just cutting the page number out of the pack to return back to the view.

Surely you should be formulating the resultant query to only be selecting the page number of records each time otherwise there is not much point.

Additionally, your controller is counting all the records a second time each call rather than just getting the count from the query before it is filtered.

No data

Runs but not getting any data in the table.
Migration run and can see the data in the TestRegisters table but not getting any in the table on run, seem to be getting a js error on line 1 of app.js

Edit: works when removing $(() => { ... }); from around the code.
Also, there's a reference to a function 'strtrunc' - is this missing? Can see it referenced in the demo at https://stackoverflow.com/questions/31809932/datatable-cell-string-truncate

Add PDF and Word output

Hello, how to create Word and PDF output both on the server side and on the client side? Of course, I mean the codes of both parts, thank you

DtParameters dtParameters error

DtParameters dtParameters can't initilize and getting ajaxy error in data loading.
Draw = 0,
search = null
column = null
length = null

[HttpPost]
public async Task LoadTable(DtParameters dtParameters, int districtid, int schoolid)
{
schoolid = 1;
var searchBy = dtParameters.Search?.Value;

        // if we have an empty search then just order the results by Id ascending
        var orderCriteria = "Id";
        var orderAscendingDirection = true;

        if (dtParameters.Order != null)
        {
            // in this example we just default sort on the 1st column
            orderCriteria = dtParameters.Columns[dtParameters.Order[0].Column].Data;
            orderAscendingDirection = dtParameters.Order[0].Dir.ToString().ToLower() == "asc";
        }
            //Direct table list into Grid
            using (var Context = new SchooldexAOIContext())
            {
                 var GridData = _context.UserSetupInfos.AsQueryable();

                if (!string.IsNullOrEmpty(searchBy))
                {
                    GridData = GridData.Where(r => r.FirstName != null && r.FirstName.ToUpper().Contains(searchBy.ToUpper()) ||
                                       r.LastName != null && r.LastName.ToUpper().Contains(searchBy.ToUpper()) ||
                                       r.Email != null && r.Email.ToUpper().Contains(searchBy.ToUpper()));                                          
                }
                GridData = orderAscendingDirection ? GridData.OrderByDynamic(orderCriteria, DtOrderDir.Asc) : GridData.OrderByDynamic(orderCriteria, DtOrderDir.Desc);

                // now just get the count of items (without the skip and take) - eg how many could be returned with filtering
                var filteredResultsCount = await GridData.CountAsync();
                var totalResultsCount =  await _context.UserSetupInfos.CountAsync();
                return Json(new DtResult<SchooldexAPI_DB.Contexts.UserSetupInfo>
                {
                    Draw = dtParameters.Draw,
                    RecordsTotal = totalResultsCount,
                    RecordsFiltered = filteredResultsCount,
                    // Data = GridData.ToList()
                    Data = await GridData
                .Skip(dtParameters.Start)
                .Take(dtParameters.Length)
                .ToListAsync()


                }); 


            }

           
        //}
        //return null;
    }

Js files

var table;

$(document).ready(function () {
// $.fn.dataTable.moment("DD/MM/YYYY HH:mm:ss");
// $.fn.dataTable.moment("DD/MM/YYYY");

table = $("#userlistgrid").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: "/Admin/LoadTable",
        type: "POST",           
        contentType: "application/json",
        dataType: "json",
        data: function (d) {
            d.districtid = 0;   //param 1
            d.schoolid = 1;    //param 2
            return JSON.stringify(d);
        }
    },
    // Columns Setups
    columns: [
        { data: "Id" },
        { data: "FirstName" },
        { data: "LastName" } ,
        { data: "Email" },
       // { data: "UserName" }
    ],
    // Column Definitions
    columnDefs: [
        { targets: "no-sort", orderable: false },
        { targets: "no-search", searchable: false },
        {
            targets: "trim",
            render: function (data, type, full, meta) {
                if (type === "display") {
                    data = strtrunc(data, 10);
                }

                return data;
            }
        },
        { targets: "date-type", type: "date-eu" },
        {
            targets: 10,
            data: null,
            defaultContent: "<a class='btn btn-link' role='button' href='#' onclick='edit(this)'>Edit</a>",
            orderable: false
        },
    ]
});

});

function strtrunc(str, num) {
if (str.length > num) {
return str.slice(0, num) + "...";
}
else {
return str;
}
}

function edit(rowContext) {
if (table) {
var data = table.row($(rowContext).parents("tr")).data();
alert("Example showing row edit with id: " + data["id"] + ", name: " + data["name"]);
}
}

MSB3021 and MSB3027 Error

Hi, I want to check the project but Ican't build it. Many thanks. Here is the error:

SSeverity Code Description Project File Line Suppression State
Error MSB3027 Could not copy "C:\Users\Ramazan.nuget\packages\system.security.cryptography.protecteddata\4.5.0\runtimes\win\lib\netstandard2.0\System.Security.Cryptography.ProtectedData.dll" to "bin\Debug\netcoreapp3.1\runtimes\win\lib\netstandard2.0\System.Security.Cryptography.ProtectedData.dll". Exceeded retry count of 10. Failed. jQueryDatatableServerSideNetCore C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\MSBuild\Current\Bin\Microsoft.Common.CurrentVersion.targets 4360
Error MSB3021 Unable to copy file "C:\Users\Ramazan.nuget\packages\system.security.cryptography.protecteddata\4.5.0\runtimes\win\lib\netstandard2.0\System.Security.Cryptography.ProtectedData.dll" to "bin\Debug\netcoreapp3.1\runtimes\win\lib\netstandard2.0\System.Security.Cryptography.ProtectedData.dll". Could not find a part of the path 'bin\Debug\netcoreapp3.1\runtimes\win\lib\netstandard2.0\System.Security.Cryptography.ProtectedData.dll'. jQueryDatatableServerSideNetCore C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\MSBuild\Current\Bin\Microsoft.Common.CurrentVersion.targets 4360

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.