Skip to content

Commit a35a70f

Browse files
Garvin CasimirGarvin Casimir
authored andcommitted
Sort index must be set for sorting to work as expected. Also added unmapped property which returns formatted date.
1 parent c5eee63 commit a35a70f

File tree

2 files changed

+15
-6
lines changed

2 files changed

+15
-6
lines changed

DataTablesParser.WebSample/Models/Person.cs

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,5 +18,14 @@ public class Person
1818
public decimal Weight { get; set; }
1919
public decimal Height { get; set; }
2020
public int Children { get; set; }
21+
22+
[NotMapped]
23+
public string BirthDateFormatted
24+
{
25+
get
26+
{
27+
return string.Format("{0:M/d/yyyy}", BirthDate);
28+
}
29+
}
2130
}
2231
}

DataTablesParser.WebSample/Views/Person/Index.cshtml

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -15,12 +15,12 @@
1515
sServerMethod: "POST",
1616
sAjaxSource: "@Url.Action("All", "Person")",
1717
aoColumns: [
18-
{ mData: "FirstName", sTitle: "First Name"},
19-
{ mData: "LastName", sTitle: "Last Name" },
20-
{ mData: "BirthDate", sTitle: "Birth Date" },
21-
{ mData: "Weight", sTitle: "Weight" },
22-
{ mData: "Height", sTitle: "Height" },
23-
{ mData: "Children", sTitle: "Children" }
18+
{ mData: "FirstName", sTitle: "First Name", iDataSort: 1 },
19+
{ mData: "LastName", sTitle: "Last Name", iDataSort:2 },
20+
{ mData: "BirthDateFormatted", sTitle: "Birth Date", iDataSort: 3 },
21+
{ mData: "Weight", sTitle: "Weight", iDataSort: 4 },
22+
{ mData: "Height", sTitle: "Height", iDataSort: 5 },
23+
{ mData: "Children", sTitle: "Children", iDataSort: 6 }
2424
2525
]
2626
});

0 commit comments

Comments
 (0)