NooBIT.DataTables 1.0.0

NooBIT.DataTables provides functionality to process ajax requests from https://datatables.net/ javascript framework v1.10.x

There is a newer version of this package available.
See the version list below for details.
Install-Package NooBIT.DataTables -Version 1.0.0
dotnet add package NooBIT.DataTables --version 1.0.0
<PackageReference Include="NooBIT.DataTables" Version="1.0.0" />
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add NooBIT.DataTables --version 1.0.0
The NuGet Team does not provide support for this client. Please contact its maintainers for support.

NooBIT.DataTables

NooBIT.DataTables provides functionality to process ajax requests from https://datatables.net javascript framework v1.10.x


Build status


Usage

Implement your custom table like this:

    public class EmployeeTable : DataTable<Employee>
    {
        public EmployeeTable(IQueryableService<Employee> queryableService) : base(queryableService)
        {
        }

        protected override Task<IQueryable<Employee>> WhereAsync(IQueryable<Employee> query, AjaxProcessingViewModel vm, AjaxColumn column, CancellationToken token)
        {
            // add your filtering here
            switch(column.Name?.ToLower())
            {
                case "name":
                    if(IsSearchable(vm.Search, column, out string name))
                    {
                        return Task.FromResult(query.Where(x => x.Name.Contains(name)));
                    }
                    break;

                case "id":
                    if(IsSearchable(vm.Search, column, out int id))
                    {
                        return Task.FromResult(query.Where(x => x.Id == id);
                    }
                    break;
            }

            return Task.FromResult(query);
        }
    }

You need some columnDefs for datatables options.
You can override the default:

    public class EmployeeTable : DataTable<Employee>
    {
        // [...]
        
        protected override Column GetColumnTemplate(PropertyInfo x, int index)
        {
            return new Column(this)
            {
                Header = new Header {DisplayName = x.GetCustomAttribute<DisplayNameAttribute>()?.DisplayName ?? x.Name},
                Name = x.Name,
                Orderable = true,
                Orders = new[]
                {
                    new Column.Order
                    {
                        ColumnName = x.Name
                    }
                },
                Render = (o, item) => o,
                Searchable = true,
                Target = index
            };
        }
    }

Or if you want complete control over column generation:

    public class EmployeeTable : DataTable<Employee>
    {
        // [...]
        
        public override List<Column> GetColumns()
        {
            return typeof(TEntity)
                .GetProperties(BindingFlags.Instance | BindingFlags.Public)
                .Select(GetColumnTemplate)
                .ToList();
        }
    }

NooBIT.DataTables

NooBIT.DataTables provides functionality to process ajax requests from https://datatables.net javascript framework v1.10.x


Build status


Usage

Implement your custom table like this:

    public class EmployeeTable : DataTable<Employee>
    {
        public EmployeeTable(IQueryableService<Employee> queryableService) : base(queryableService)
        {
        }

        protected override Task<IQueryable<Employee>> WhereAsync(IQueryable<Employee> query, AjaxProcessingViewModel vm, AjaxColumn column, CancellationToken token)
        {
            // add your filtering here
            switch(column.Name?.ToLower())
            {
                case "name":
                    if(IsSearchable(vm.Search, column, out string name))
                    {
                        return Task.FromResult(query.Where(x => x.Name.Contains(name)));
                    }
                    break;

                case "id":
                    if(IsSearchable(vm.Search, column, out int id))
                    {
                        return Task.FromResult(query.Where(x => x.Id == id);
                    }
                    break;
            }

            return Task.FromResult(query);
        }
    }

You need some columnDefs for datatables options.
You can override the default:

    public class EmployeeTable : DataTable<Employee>
    {
        // [...]
        
        protected override Column GetColumnTemplate(PropertyInfo x, int index)
        {
            return new Column(this)
            {
                Header = new Header {DisplayName = x.GetCustomAttribute<DisplayNameAttribute>()?.DisplayName ?? x.Name},
                Name = x.Name,
                Orderable = true,
                Orders = new[]
                {
                    new Column.Order
                    {
                        ColumnName = x.Name
                    }
                },
                Render = (o, item) => o,
                Searchable = true,
                Target = index
            };
        }
    }

Or if you want complete control over column generation:

    public class EmployeeTable : DataTable<Employee>
    {
        // [...]
        
        public override List<Column> GetColumns()
        {
            return typeof(TEntity)
                .GetProperties(BindingFlags.Instance | BindingFlags.Public)
                .Select(GetColumnTemplate)
                .ToList();
        }
    }

NuGet packages (1)

Showing the top 1 NuGet packages that depend on NooBIT.DataTables:

Package Downloads
NooBIT.DataTables.AspNetCore.Mvc
NooBIT.DataTables provides functionality to process ajax requests from https://datatables.net javascript framework v1.10.x

GitHub repositories

This package is not used by any popular GitHub repositories.

Version History

Version Downloads Last updated
4.0.0 148 11/15/2019
3.0.0 249 1/30/2019
2.2.7 219 11/30/2018
2.2.6 240 11/29/2018
2.2.5 232 11/29/2018
2.2.4 200 11/29/2018
2.2.3 197 11/29/2018
2.2.0 216 11/8/2018
2.1.1 205 11/8/2018
2.1.0 200 11/8/2018
2.0.3 220 11/7/2018
2.0.2 265 11/7/2018
2.0.1 210 11/7/2018
2.0.0 206 11/7/2018
1.4.1 309 11/2/2018
1.4.0 220 11/2/2018
1.3.1 199 10/31/2018
1.3.0 242 10/26/2018
1.2.4 242 10/26/2018
1.2.3 216 10/26/2018
1.2.2 221 10/26/2018
1.2.1 235 10/26/2018
1.2.0 209 10/26/2018
1.1.8 232 9/26/2018
1.1.7 250 9/26/2018
1.0.6 220 9/26/2018
1.0.0 376 5/31/2018
Show less