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
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.
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.
This discussion has been closed.
Replies
Allan