-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathDataTablesRequest.cs
68 lines (60 loc) · 1.69 KB
/
DataTablesRequest.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
using System.Collections.Generic;
namespace ServerSideDataTable
{
public class DataTablesRequest
{
public int Draw { get; set; }
public int Start { get; set; }
public int Length { get; set; }
public Search Search { get; set; } = new Search();
public List<Order> Order { get; set; } = new List<Order>();
public IEnumerable<Column> Columns { get; set; }
public IDictionary<string, object> AdditionalParameters { get; set; }
}
public class Sort
{
public SortDirection Dir { get; set; }
public int Column { get; set; }
public void SetSortDirection(string direction)
{
if (direction.Equals("asc"))
{
this.Dir = SortDirection.Asc;
}
else
{
this.Dir = SortDirection.Desc;
}
}
}
public class Search
{
public string Value { get; set; }
public bool IsRegex { get; set; }
}
public class Order
{
public int Column { get; set; }
public string Dir { get; set; }
}
public class Column
{
public bool SetSort(int order, int direction)
{
Sort.Column = order;
Sort.Dir = direction == 0 ? SortDirection.Asc : SortDirection.Desc;
return IsSortable;
}
public string Name { get; set; }
public string Field { get; set; }
public bool IsSearchable { get; set; }
public Search Search { get; set; }
public bool IsSortable { get; set; }
public Sort Sort { get; set; }
}
public enum SortDirection
{
Asc = 0,
Desc = 1
}
}