Hi,
I'm trying to make paging work on the server side for large numbers of records. If I set schema.total to an arbitrary hard coded number then i start to see paging as expected. However I would like to return the total number of records by way of an additional angularjs rest call that is just responsible for a returning a data count.
$scope.m = {
dataDetailedDs: new kendo.data.DataSource({
type: "read",
transport: {
read: {
url: "api/Data",
dataType: "json"
}
},
schema: {
type: "json",
data: "value",
total: function() {
$http.get('api/Data/NumberOfRecords').
success(function(d) {
$scope.m.dataDetailedDs.total = d;
//also tried
//return d;
//
//also tried
//return 10000;
});
},
model: {
fields: {
Name: { type: "string" },
ProjectId: { type: "number" },
DataTypeId: { type: "number" },
AlternativeName: { type: "string" },
Guid: { type: "string" },
Hashcode: { type: "string" },
LastmodifiedTime: { type: "date" }
}
}
},
pageSize: 20,
serverPaging: true,
serverFiltering: true,
serverSorting: true,
I can verify the success call back occurs but I cant get the grid to update itself to recognise it has pages. I assume this is because the total rest call is async and the grid doesn't then become updated.
I guess this is the wrong way to go about it, please can you help?
I didn't particularly want to wrap my entity objects in another object which has a field containing the total number of records...
As an aside i was using odata previously and got all this for free which was great until i ran into performance problems in sql server due to the generated queries from the entity framework. Sp_exexcute sql is doing lots of parameter sniffing and causing bad execution paths so queries are timing out. If a tweak the queries myself within sql server and add option recompile i can resolve the parameter sniffing bad execution path performance issues but unfortunately I don't have any control over the generated queries. if you have any thoughts on this and how to get around the issue I would also appreciate it!
Thanks for your help!
Doug
I'm trying to make paging work on the server side for large numbers of records. If I set schema.total to an arbitrary hard coded number then i start to see paging as expected. However I would like to return the total number of records by way of an additional angularjs rest call that is just responsible for a returning a data count.
$scope.m = {
dataDetailedDs: new kendo.data.DataSource({
type: "read",
transport: {
read: {
url: "api/Data",
dataType: "json"
}
},
schema: {
type: "json",
data: "value",
total: function() {
$http.get('api/Data/NumberOfRecords').
success(function(d) {
$scope.m.dataDetailedDs.total = d;
//also tried
//return d;
//
//also tried
//return 10000;
});
},
model: {
fields: {
Name: { type: "string" },
ProjectId: { type: "number" },
DataTypeId: { type: "number" },
AlternativeName: { type: "string" },
Guid: { type: "string" },
Hashcode: { type: "string" },
LastmodifiedTime: { type: "date" }
}
}
},
pageSize: 20,
serverPaging: true,
serverFiltering: true,
serverSorting: true,
I can verify the success call back occurs but I cant get the grid to update itself to recognise it has pages. I assume this is because the total rest call is async and the grid doesn't then become updated.
I guess this is the wrong way to go about it, please can you help?
I didn't particularly want to wrap my entity objects in another object which has a field containing the total number of records...
As an aside i was using odata previously and got all this for free which was great until i ran into performance problems in sql server due to the generated queries from the entity framework. Sp_exexcute sql is doing lots of parameter sniffing and causing bad execution paths so queries are timing out. If a tweak the queries myself within sql server and add option recompile i can resolve the parameter sniffing bad execution path performance issues but unfortunately I don't have any control over the generated queries. if you have any thoughts on this and how to get around the issue I would also appreciate it!
Thanks for your help!
Doug