DataTableServerSide.AspNetCore 1.0.1

dotnet add package DataTableServerSide.AspNetCore --version 1.0.1                
NuGet\Install-Package DataTableServerSide.AspNetCore -Version 1.0.1                
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="DataTableServerSide.AspNetCore" Version="1.0.1" />                
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add DataTableServerSide.AspNetCore --version 1.0.1                
#r "nuget: DataTableServerSide.AspNetCore, 1.0.1"                
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
// Install DataTableServerSide.AspNetCore as a Cake Addin
#addin nuget:?package=DataTableServerSide.AspNetCore&version=1.0.1

// Install DataTableServerSide.AspNetCore as a Cake Tool
#tool nuget:?package=DataTableServerSide.AspNetCore&version=1.0.1                

DataTableServerSide.AspNetCore

This library is designed to facilitate server-side table operations using the DataTables plugin in your ASP.NET Core projects.

How to Use

  1. Installation
  • NuGet üzerinden kütüphaneyi projenize ekleyin.

    dotnet add package DataTableServerSide.AspNetCore
    
  1. Model Creation
  • Create your model class.

    public class PersonModel
    {
        public int Id { get; set; }
        public string FirstName { get; set; }
        public string LastName { get; set; }
        public string Phone { get; set; }
        public string Mail { get; set; }
        public string Address { get; set; }
        public int Age { get; set; }
    }
    
  1. Usage in Controller

    using Bogus;
    using DataTableServerSide.AspNetCore;
    using Microsoft.AspNetCore.Mvc;
    using System.Collections.Generic;
    
    public class HomeController : Controller
    {
        public IActionResult Index()
        {
            return View();
        }
    
        [HttpPost]
        public JsonResult GetPersons()
        {
            var personList = Persons();
            var dataTableHelper = new DataTableHelper<YourModel>(data, Request);
            var result = dataTableHelper.GetDataTableResult();
            return Json(result);
        }
    
        public List<PersonModel> Persons()
        {
            List<PersonModel> persons = new();
    
            var faker = new Faker();
    
            for (int i = 0; i < 10000; i++)
            {
                PersonModel person = new()
                {
                    Id = i + 1,
                    FirstName = faker.Name.FirstName(),
                    LastName = faker.Name.LastName(),
                    Phone = faker.Phone.PhoneNumberFormat(),
                    Mail = faker.Internet.Email(),
                    Address = faker.Address.FullAddress(),
                    Age = faker.Random.Number(18, 80)
    
                };
                persons.Add(person);
            }
    
            return persons;
        }
    }
    
  2. DataTable Settings on the Client Side

    Configure DataTable on your HTML page as follows:

    <div class="mb-5 mt-5">
        <h2>Person Lists</h2>
        <hr />
        <table id="myTable" class="table">
            <thead>
                <tr>
                    <th scope="col">#</th>
                    <th scope="col">FirstName</th>
                    <th scope="col">LastName</th>
                    <th scope="col">Phone</th>
                    <th scope="col">Email</th>
                    <th scope="col">Address</th>
                    <th scope="col">Age</th>
                </tr>
            </thead>
        </table>
    </div>
    

    Configure DataTable with JavaScript:

    $(document).ready(function () {
       $(document).ready(function () {
        var table = $('#myTable').dataTable({
            lengthMenu: [[10, 25, 50, 100], [10, 25, 50, 100]],
            pageLength: 10,
            processing: true,
            serverSide: true,
            filter: true,
            ordering: true,
            ajax: {
                url: "/Home/GetPersons",
                type: "POST",
                datatype: "json"
            },
            columns: [
                { data: "id", name: "id" },
                { data: "firstName", name: "firstName" },
                { data: "lastName", name: "lastName" },
                { data: "phone", name: "phone" },
                { data: "mail", name: "mail" },
                { data: "address", name: "address" },
                { data: "age", name: "age" }
            ]
        });
    
  3. Example Usage

    • Create a model that fits your PersonModel class.
    • Provide the appropriate data for the GetDataTable method in the Controller..
    • Integrate DataTable into your relevant HTML page and configure it with JavaScript.
  4. Custom Filtering and Sorting Logic

    The library allows you to customize data filtering and sorting. You can add your logic by modifying the ApplyFilters and ApplySorting methods.

Contributing

If you find an issue or want to contribute, please open an issue or submit a pull request.

Project Demo

You can check out the Project Demo.

License

This project is licensed under the MIT lisansı. You can review the license file for detailed information.

Product Compatible and additional computed target framework versions.
.NET net5.0 was computed.  net5.0-windows was computed.  net6.0 was computed.  net6.0-android was computed.  net6.0-ios was computed.  net6.0-maccatalyst was computed.  net6.0-macos was computed.  net6.0-tvos was computed.  net6.0-windows was computed.  net7.0 was computed.  net7.0-android was computed.  net7.0-ios was computed.  net7.0-maccatalyst was computed.  net7.0-macos was computed.  net7.0-tvos was computed.  net7.0-windows was computed.  net8.0 was computed.  net8.0-android was computed.  net8.0-browser was computed.  net8.0-ios was computed.  net8.0-maccatalyst was computed.  net8.0-macos was computed.  net8.0-tvos was computed.  net8.0-windows was computed. 
.NET Core netcoreapp3.0 was computed.  netcoreapp3.1 was computed. 
.NET Standard netstandard2.1 is compatible. 
MonoAndroid monoandroid was computed. 
MonoMac monomac was computed. 
MonoTouch monotouch was computed. 
Tizen tizen60 was computed. 
Xamarin.iOS xamarinios was computed. 
Xamarin.Mac xamarinmac was computed. 
Xamarin.TVOS xamarintvos was computed. 
Xamarin.WatchOS xamarinwatchos was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

NuGet packages

This package is not used by any NuGet packages.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last updated
1.0.1 147 2/5/2024
1.0.0 112 2/2/2024

This library is designed to facilitate server-side table operations using the DataTables plugin in your ASP.NET Core projects.