I have an Angular JS app. When I browse to a new page and go back to the page with the grid, I receive the following error:
"Uncaught Error: Cannot call method 'value' of kendoDropDownList before it is initialized"
Datasource:
app.factory('giftService', ['coreSettings', function (coreSettings) {
var giftServiceFactory = {};
var crudServiceBaseUrl = coreSettings.apiServiceBaseUri + "odata/Order";
var ds = new kendo.data.DataSource({
type: "odata",
transport: {
read: {
url: crudServiceBaseUrl,
dataType: "json"
}
},
batch: false,
serverPaging: true,
pageSize:10,
serverSorting: true,
serverFiltering: true,
aggregate: [
{ field: "Amount", aggregate: "sum" }
],
schema: {
errors: function (response) {
if (response.Errors) {
return (response.Errors);
this.cancelChanges();
}
},
data: function (data) { return data.value; },
total: function (data) { return data["odata.count"]; },
model: {
fields: {
...
}
}
},
error: function (e) {
return (e.xhr.responseText);
this.cancelChanges();
},
success: function (e) {
alert('Success!');
}
})
giftServiceFactory.ds = ds;
return giftServiceFactory;
}]);
Angular Controller:
$scope.gifts = salesService.GetAllGifts();
$scope.gridOptions = {
toolbar: ["excel"],
excel: {
fileName: "Exclusively Gifted Sales.xlsx",
filterable: true,
allPages: true
},
sortable: true,
selectable: true,
reorderable: true,
groupable: true,
columnmenu: true,
pageable: {
refresh: true,
pageSizes: true,
pageSize: 10,
messages: {
refresh: "Refresh the grid"
}
},
filterable: true ,
dataSource: $scope.gifts,
columns: [
{ field: "PurchaserName", title: "Purchaser" },
{ field: "SendMethodPurchaser", title: "Purchaser Email" },
{ field: "RecipientName", title: "Recipient" },
{
field: "Amount", format: "{0:c}", aggregates: ["sum"],
footerTemplate: "Total Amount: #= kendo.toString(sum, 'C') #",
groupFooterTemplate: "Total : #= kendo.toString(sum, 'C') #"
},
{ field: "PurchaseDate", title: "Purchased", format: "{0:yyyy-MM-dd}" },
{ field: "SendDate", title: "Sent", format: "{0:yyyy-MM-dd}" },
{ field: "RedeemedDate", title: "Redeemed", format: "{0:yyyy-MM-dd}" }
]
};
Do you have any suggestions as to what can be causing this behavior? When I remove the paging the issue does not occur. Many thanks,
Jayme