Janar.DataTable 1.1.6

dotnet add package Janar.DataTable --version 1.1.6
                    
NuGet\Install-Package Janar.DataTable -Version 1.1.6
                    
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="Janar.DataTable" Version="1.1.6" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="Janar.DataTable" Version="1.1.6" />
                    
Directory.Packages.props
<PackageReference Include="Janar.DataTable" />
                    
Project file
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add Janar.DataTable --version 1.1.6
                    
#r "nuget: Janar.DataTable, 1.1.6"
                    
#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.
#:package Janar.DataTable@1.1.6
                    
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package.
#addin nuget:?package=Janar.DataTable&version=1.1.6
                    
Install as a Cake Addin
#tool nuget:?package=Janar.DataTable&version=1.1.6
                    
Install as a Cake Tool

๐Ÿ“Š Janar.DataTable

A powerful, flexible, and modern data table component for Blazor Server and MAUI Blazor Hybrid apps.
Built to support dynamic columns, rich formatting, searching, pagination, and client-side export โ€” all styled with Bootstrap 5.


โ˜• Support

If you find this package helpful, please consider supporting me:

Buy Me A Coffee


โœจ Features

  • ๐Ÿ”„ Dynamic Columns via reflection
  • โš™๏ธ Custom Column Configuration (name, order, visibility)
  • โ†•๏ธ Sortable Headers
  • ๐Ÿ” Search Filtering
  • ๐Ÿ“„ Pagination
  • ๐Ÿ“ค Export to CSV, Excel, and PDF (client-side)
  • ๐ŸŽจ Bootstrap 5 Styling
  • ๐Ÿ› ๏ธ Action Buttons Support (Edit/Delete)
  • ๐Ÿงฉ Custom Column Templates via RenderFragment

๐Ÿš€ Getting Started

โœ… Basic Usage

Use Janar.DataTable with auto-generated columns:

<DataTable TItem="Employee"
           Items="@employees" />

โš™๏ธ Advanced Usage

1. ๐Ÿ› ๏ธ Column Configuration

Define custom column headers, visibility, order, and templates:

private List<ColumnConfiguration> columnConfigurations = new()
{
    new() { PropertyName = "Id", HeaderName = "ID", Order = 1, Visible = true },
    new() { PropertyName = "Name", HeaderName = "Full Name", Order = 2, Visible = true },
    new() { PropertyName = "Position", HeaderName = "Position", Order = 3, Visible = true },
    new() { PropertyName = "Office", HeaderName = "Office", Order = 4, Visible = true },
    new() { PropertyName = "Salary", HeaderName = "Salary", Order = 5, Visible = true, Template = customEmployee },
    new() { PropertyName = "JoiningDate", HeaderName = "Joining Date", Order = 6, Visible = true },
    new() { PropertyName = "LoginTime", HeaderName = "Login Time", Order = 7, Visible = true, Template = lgnTime },
    new() { PropertyName = "YearsAtCompany", HeaderName = "Years At Company", Order = 8, Visible = true }
};
<DataTable TItem="Employee"
           Items="@employees"
           ColumnConfigurations="@columnConfigurations" />

2. ๐ŸŽฏ Column Formatting

Format data (e.g., currency, dates, numbers) using ColumnFormats:

private Dictionary<string, string> columnFormats = new()
{
    { "Salary", "C2" },               // $62,000.00
    { "JoiningDate", "dd-MMM-yyyy" }, // 10-Apr-2018
    { "YearsAtCompany", "N0" }        // 5
};
<DataTable TItem="Employee"
           Items="@employees"
           ColumnFormats="@columnFormats"
           ColumnConfigurations="@columnConfigurations" />

3. ๐ŸŽจ Custom Templates with RenderFragment

Use RenderFragment<T> for custom rendering:

private static RenderFragment<Employee> customEmployee => emp => builder =>
{
    builder.OpenElement(0, "span");
    builder.AddAttribute(1, "class", "btn btn-sm btn-primary me-2");
    builder.AddContent(2, emp.Salary.ToString("C0"));
    builder.CloseElement();
};

private static RenderFragment<Employee> lgnTime => emp => builder =>
{
    builder.OpenElement(0, "span");
    builder.AddAttribute(1, "class", "badge bg-info");
    builder.AddContent(2, emp.Logintime.ToString("HH:mm:ss"));
    builder.CloseElement();
};
<DataTable TItem="Employee"
           Items="@employees"
           ColumnConfigurations="@columnConfigurations" />

4. ๐Ÿงฐ Action Buttons (Edit/Delete)

Define handlers for editing and deleting rows:

private void EditItem(Employee employee)
{
    // Handle edit logic here
}

private void DeleteItem(Employee employee)
{
    // Handle delete logic here
}
<DataTable TItem="Employee"
           Items="@employees"
           OnEdit="EditItem"
           OnDelete="DeleteItem" />

๐Ÿ“ฆ Export Functionality

When ExportButtons = true, the component shows export buttons for CSV, Excel, and PDF.

โœ… Required CSS

Include these in your layout file (e.g., _Host.cshtml, App.cshtml, index.html, or MauiBlazorHostPage.xaml):

<link href="https://fonts.googleapis.com/icon?family=Material+Icons+Outlined" rel="stylesheet">
<link href="_content/Janar.Datatable/assets/css/datatable.css" rel="stylesheet" />

โš ๏ธ Note

If _content/Janar.Datatable/assets/css/datatable.css doesn't apply styles correctly,
you can download datatable.css manually from:

๐Ÿ”— GitHub Demo Repository

โœ… Required Scripts

Place these before the closing </body> tag:

<script src="https://cdnjs.cloudflare.com/ajax/libs/xlsx/0.18.5/xlsx.full.min.js"></script>
<script src="_content/Janar.Datatable/assets/js/datatable.js"></script>
<script src="_content/Janar.Datatable/assets/js/exporter.js"></script>

๐Ÿงฉ Component Parameters

Parameter Type Description
TItem Type Generic item type (e.g., Employee)
Items IEnumerable<TItem> Data source for the table
ColumnFormats Dictionary<string, string> Format strings per column
ColumnConfigurations List<ColumnConfiguration> Header, visibility, order, templates
OnEdit EventCallback<TItem> Row Edit button callback
OnDelete EventCallback<TItem> Row Delete button callback
ExportButtons bool Shows export buttons (CSV, Excel, PDF)
ActionsButtons bool Shows Edit/Delete buttons
Search bool Enables search input
TableStyle string Bootstrap classes to style the table
UndefinedColumns bool Auto-detect and display public props

๐Ÿงช Full Integration Example

<DataTable5 TItem="Employee"
            Items="@employees"
            ColumnConfigurations="@clmnOrderConfigs"
            OnEdit="EditEmployee"
            OnDelete="DeleteEmployee"
            ExportButtons="false"
            Search="false" 
            TableStyle="table-dark table-striped table-bordered"
            ActionsButtons="false"
            UndefinedColumns="false" />

๐Ÿ—๏ธ Column Configuration Example

private List<ColumnConfigWithOrder<Employee>> clmnOrderConfigs = new()
{
    new() { PropertyName = "DefinedName", Visible = true, Header = "Name", Align = "left", Order = 1 },
    new() { PropertyName = "EmployeePosition", Visible = true, Header = "Position", Align = "center", Order = 2 },
    new() { PropertyName = "EmployeeSalary", Visible = true, Header = "Salary ๐Ÿ’ฐ", Align = "right", Order = 3,
             Template = employee => @<span class="text-success fw-bold">@employee.Salary.ToString("C0")</span> },
    new() { PropertyName = "EmployeeYearsAtCompany", Visible = true, Header = "Years @ Co.โณ", Align = "center", Order = 4,
             Template = employee => @<span class="badge bg-info">@employee.YearsAtCompany</span> }
};
  • Template allows custom rendering using RenderFragment<TItem>
  • Align controls text alignment (left, center, right)
  • Order determines column display order
  • Visible shows or hides the column

โš™๏ธ Behavior: UndefinedColumns

  • If UndefinedColumns = true (default):

    • All public properties on TItem are auto-detected and displayed
    • You can override properties via ColumnConfigurations
  • If UndefinedColumns = false:

    • Only columns defined in ColumnConfigurations with Visible = true are shown

This gives you flexibility for both quick setup and fine-grained control.


๐ŸŽจ Styling Tips

  • Use the TableStyle parameter to apply Bootstrap classes:
TableStyle="table table-dark table-striped table-bordered"
  • To add rounded corners:
.table-wrapper {
    border-radius: 5px;
    overflow: hidden;
}

Wrap your <table> with a .table-wrapper div to enable rounded borders.

  • Customize sorting icons by overriding classes like:

    • .sort-indicator
    • .sort-arrow
    • .sort-active
    • .sort-disabled

โš ๏ธ .NET 8 Interactive Notice

If you're

using Blazor Web Components in .NET 8, ensure the component is rendered with an interactive render mode like:

@rendermode="InteractiveServer"

Otherwise, features such as search, sort, and pagination will not function.


๐Ÿ“Œ Versioning & Changes

When updating versions, ensure the following are reflected:

  • โœ… Added Parameters:

    • ExportButtons
    • ActionsButtons
    • Search
    • TableStyle
    • UndefinedColumns
  • โš ๏ธ Changed Behavior:

    • With UndefinedColumns = true, all columns are auto-detected unless configured
  • ๐ŸŽจ CSS & Styling Updates:

    • Improved dark mode support
    • Enhanced sorting styles
    • Better Bootstrap 5 compatibility

๐Ÿ“š GitHub Demo

GitHub Demo Link


๐Ÿงพ License

MIT ยฉ [Janar Group]


๐Ÿ™ Acknowledgments

  • Uses SheetJS for Excel exports
  • Built with โค๏ธ by Janar Group using Blazor and Bootstrap 5

Buy Me a Coffee

Thank you for using Janar.DataTable!

Product Compatible and additional computed target framework versions.
.NET net8.0 is compatible.  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.  net9.0 was computed.  net9.0-android was computed.  net9.0-browser was computed.  net9.0-ios was computed.  net9.0-maccatalyst was computed.  net9.0-macos was computed.  net9.0-tvos was computed.  net9.0-windows was computed.  net10.0 was computed.  net10.0-android was computed.  net10.0-browser was computed.  net10.0-ios was computed.  net10.0-maccatalyst was computed.  net10.0-macos was computed.  net10.0-tvos was computed.  net10.0-windows 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.1.6 226 10/8/2025
1.1.5 216 10/8/2025
1.1.4 213 10/7/2025
1.1.3 215 10/7/2025
1.1.2 294 10/7/2025 1.1.2 is deprecated because it has critical bugs.
1.1.1 297 10/6/2025 1.1.1 is deprecated because it has critical bugs.
1.1.0 205 10/6/2025
1.0.0 198 10/4/2025