Server Side Paging: Is it possible to pass a System.Data.Datable in the JQueryDataTablesResponse

Server Side Paging: Is it possible to pass a System.Data.Datable in the JQueryDataTablesResponse

kayokayo Posts: 1Questions: 0Answers: 0
edited January 2014 in General
Hi,

I am very new to the jquery DataTable and hope someone can assist me.

I have implemented server side paging, my call to the database returns a datatable of type System.Data.DataTable, it is not possible for me to put this data into a model as it is working of dynamic views.

My server side code is as follows:

public JsonResult DataPage(JQueryDataTablesModel jdtm, string whereClause)
{

DataTable results = GetData(whereClause,jdtm.iDisplayLength, jdtm.iDisplayStart);


return Json(new JQueryDataTablesResponse(
items: results.AsEnumerable(),
totalRecords: 80,
totalDisplayRecords: 10,
sEcho: jdtm.sEcho));

however no data displays, even though data has been retrieved from the database. Any suggestions would be greatly appreciated.

My jquery is as follows:

$('#tblQueryResults').dataTable({
sScrollX: "100%",
bPaginate: true,
bFilter: false,
sPaginationType: "full_numbers",
sDom: 't<"queryResultsFooter"i<"exportToExcel">p>r',
bProcessing: true,
bInfo: true,
bSort: true,
bSortClasses: true,
oLanguage: {
"sInfoEmpty": 'No entries to show',
"sEmptyTable": "No data found matching search criteria",
},
bServerSide: true, //turning on server side paging
sAjaxSource: "/TestApp/Home/DataPage?whereClause=" + whereClause,


});

my .cshtml page is as follows:

@Html.Hidden("WhereClause", Model.WhereClause);






@foreach (System.Data.DataColumn col in Model.Results.Columns)
{
@col.Caption
}




}

Any suggestions as to how to get the data to display would be much appreciated.
Thanks.

Replies

  • allanallan Posts: 63,498Questions: 1Answers: 10,471 Site admin
    Possibly someone else might be able to help, but I'm afraid I can't myself. You might have better luck asking in a .NET forum, as this appears to be a .NET (ASP?) issue more than a Javascript issue.

    Allan
This discussion has been closed.