C# ServerSide not working
C# ServerSide not working
I have created an api but it loads all the data and ignore serverside:true, please help?
$(document).ready(function () {
$.ajax({
"dataType": "application/json",
"type": "GET",
"url": "http://localhost:54888/api/order",
"success": function (dataStr) {
console.log(dataStr.responseText);
// laod Data to DataTable Jquery
var resp = jQuery.parseJSON(dataStr.responseText ? dataStr.responseText : dataStr);
$('#example').DataTable({
data: resp["rows"],
columns: resp["aoColumns"],
scrollX: true,
autoWidth: true,
bScrollCollapse: true,
// paging: true,
// retrieve: true,
"jQueryUI": true,
/serverSide: true,
processing:true
});
},
"error": function (dataStr) {
//console.log(dataStr);
var resp = jQuery.parseJSON(dataStr.responseText ? dataStr.responseText : dataStr);
$('#example').DataTable({
data: resp["rows"],
columns: resp["aoColumns"],
scrollX: true,
autoWidth: true,
bScrollCollapse: true,
//paging: true,
//retrieve: true,
"jQueryUI": true,
serverSide: true,
processing: true
});
}
})
});
Answers
Does your server script support the communications protocol described here:
https://datatables.net/manual/server-side
Your server script is responsible for returning the correct rows.
Kevin
Yes, Here is my server Script
using (var db = new Database(settings.DbType, settings.DbConnection))
{
var response = new Editor(db, "tbl_Order")
.Model<orders>()
.Field(new Field("Reference")
// .Validator(Validation.NotEmpty())
)
.Field(new Field("Comments")
//.Validator(Validation.NotEmpty())
)
.Process(request)
.Data();
Its unclear to me from that code what your SQL query is doing. Does your SQL query use limit, offset and order by to perform a query that only returns the rows for the page being displayed?
Kevin
Thank you for your reply,
the SQl query is a stored proc, its just link up a few tables and return a select
Regards,
Yosh