Created
January 13, 2024 20:11
-
-
Save chrcar01/3a1e0c597233dc8449d0a47a5ce405de to your computer and use it in GitHub Desktop.
jQuery DataTables models
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class DataTableSearch | |
{ | |
public string? Value | |
{ | |
get; set; | |
} | |
public bool Regex | |
{ | |
get; set; | |
} | |
} | |
public class DataTableRequest | |
{ | |
private string? _orderByField; | |
public string OrderByField | |
{ | |
get => _orderByField ??= Order.Count > 0 && Columns.Count > 0 ? Columns[Order[0].Column].Data ?? string.Empty : string.Empty; | |
set => _orderByField = value; | |
} | |
private string? _orderByDirection; | |
public string OrderByDirection | |
{ | |
get => _orderByDirection ??= Order.Count > 0 ? Order[0].Dir ?? "asc" : "asc"; | |
set => _orderByDirection = value; | |
} | |
private int? _pageIndex; | |
public int PageIndex | |
{ | |
get => _pageIndex ??= Length > 0 ? Start / Length + 1 : 1; | |
set => _pageIndex = value; | |
} | |
private int? _pageSize; | |
public int PageSize | |
{ | |
get => _pageSize ??= Length > 0 ? Length : 10; | |
set => _pageSize = value; | |
} | |
public int Draw | |
{ | |
get; set; | |
} | |
public int Start | |
{ | |
get; | |
set; | |
} | |
private int _length; | |
public int Length | |
{ | |
get => _length; | |
set | |
{ | |
_length = value; | |
PageSize = value; | |
} | |
} | |
private List<DataTableColumn>? _columns; | |
public List<DataTableColumn> Columns | |
{ | |
get => _columns ??= new List<DataTableColumn>(); | |
set => _columns = value; | |
} | |
private List<DataTableOrder>? _order; | |
public List<DataTableOrder> Order | |
{ | |
get => _order ??= new List<DataTableOrder>(); | |
set => _order = value; | |
} | |
public DataTableSearch? Search | |
{ | |
get; set; | |
} | |
} | |
public class DataTableOrder | |
{ | |
public int Column | |
{ | |
get; set; | |
} | |
public string? Dir | |
{ | |
get; set; | |
} | |
} | |
public class DataTableColumn | |
{ | |
public string? Data | |
{ | |
get; set; | |
} | |
public string? Name | |
{ | |
get; set; | |
} | |
public bool Searchable | |
{ | |
get; set; | |
} | |
public bool Orderable | |
{ | |
get; set; | |
} | |
public DataTableSearch? Search | |
{ | |
get; set; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment