Skip to content

Commit e866e9b

Browse files
committed
Fixed Order attribute
1 parent 15df137 commit e866e9b

File tree

2 files changed

+6
-5
lines changed

2 files changed

+6
-5
lines changed

Mvc.JQuery.Datatables.Example/Controllers/HomeController.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -51,12 +51,12 @@ public DataTablesResult<UserView> GetUsers(DataTablesParam dataTableParam)
5151

5252
public class UserView
5353
{
54-
[DataTables(SortDirection = SortDirection.Ascending)]
55-
public int Id { get; set; }
56-
54+
5755
[DataTables(DisplayName = "Full Name", MRenderFunction = "test")]
5856
public string Name { get; set; }
5957

58+
[DataTables(SortDirection = SortDirection.Ascending, Order = 0)]
59+
public int Id { get; set; }
6060

6161
[DataTables(Searchable = false)]
6262
public string Email { get; set; }

Mvc.JQuery.Datatables/DataTablesTypeInfo.cs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ static DataTablesTypeInfo()
1414
{
1515
var infos = from pi in typeof (T).GetProperties()
1616
let da = (DataTablesAttribute)(pi.GetCustomAttributes(typeof(DataTablesAttribute), false).SingleOrDefault() ?? new DataTablesAttribute())
17-
orderby da.Order ?? int.MaxValue
17+
orderby da.Order
1818
select new DataTablesPropertyInfo(pi, da);
1919
Properties = infos.ToArray();
2020
}
@@ -50,11 +50,12 @@ public DataTablesAttribute()
5050
this.Sortable = true;
5151
this.Searchable = true;
5252
this.Visible = true;
53+
this.Order = int.MaxValue;
5354
}
5455

5556
public bool Searchable { get; set; }
5657
public bool Sortable { get; set; }
57-
public int? Order { get; set; }
58+
public int Order { get; set; }
5859
public string DisplayName { get; set; }
5960
public SortDirection SortDirection { get; set; }
6061
public string MRenderFunction { get; set; }

0 commit comments

Comments
 (0)