Created
February 19, 2012 02:18
-
-
Save tawman/1861658 to your computer and use it in GitHub Desktop.
PetaPocoPage Helper to format the JSON page response to DataTables
This file contains hidden or 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
using System.Globalization; | |
using System.Linq; | |
using PetaPoco; | |
using PetaPocoPage.Models; | |
namespace PetaPocoPage.Helpers | |
{ | |
public class DataTablesFormat | |
{ | |
public static object PageResponse(DataTablesPageRequest pageRequest, Page<Customer> report) | |
{ | |
return new | |
{ | |
sEcho = pageRequest.Echo, | |
iTotalRecords = report.TotalItems, | |
iTotalDisplayRecords = report.TotalItems, | |
sColumns = pageRequest.ColumnNames, | |
aaData = (from i in report.Items | |
select new[] | |
{ | |
i.Id.ToString(CultureInfo.InvariantCulture), | |
i.Last, | |
i.First, | |
i.Street, | |
i.City, | |
i.State, | |
i.Zip, | |
i.Phone, | |
i.Email | |
}).ToList() | |
}; | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment