Good morning , we upgrade to version 2015.2.827 , and several components have stopped working . Apparently this giving an internal error that could not figure out
The error occurs in the function below.
File Name: kendo.web.js
/// ====================================================================
function calculateAggregate(accumulator, aggregates, item, index, length, state) {
aggregates = aggregates || [];
var idx,
aggr,
functionName,
len = aggregates.length;
for (idx = 0; idx < len; idx++) {
aggr = aggregates[idx];
functionName = aggr.aggregate;
var field = aggr.field;
accumulator[field] = accumulator[field] || {};
state[field] = state[field] || {};
state[field][functionName] = state[field][functionName] || {};
accumulator[field][functionName] = functions[functionName.toLowerCase()](accumulator[field][functionName], item, kendo.accessor(field), index, length, state[field][functionName]);
}
}
==============================================================================================
Error: Uncaught TypeError: Cannot read property 'toLowerCase' of undefined
9 Answers, 1 is accepted
This does not sound like a known issue. Is it possible for you to isolate the case in a separate project with mock data so I can examine it and assist you further?
Regards,
Alexander Valchev
Telerik
Hi Alexander.
I have created a demo example of my problem with a code closer than mine here: http://dojo.telerik.com/idoVo
It works, so the issue is in my code. The widget(kendoTreeView) is created with the parameters as shown in the "img3.png" attachment. Its dataSource(HierarchicalDataSource) uses a custom read method, as shown in the "img1.png" attachment. The data used in the demo is my real data. The content of this url(https://api.myjson.com/bins/1axc8) is the same in the attachment "img1.png" screenshot. It is the same data passed to options.success(data). The problem is that inside it - check the "img2.png" attachment - it throws an error with something related to "aggregate" data, and I don't know what may causing this. No dataSource have any aggregate function defined.
Thank you for the example and for the detailed information.
I am not aware of any known issue that might be the reason of the error that you receive. Is the Kendo UI version in your project the same as the one used in the working Dojo test page? If it's not please try upgrading and see if the issue still persists. If it is the same, I will need a runnable sample project with mock data that demonstrates the issue. In this way I will be able to debug the Kendo UI Source and find out what causes the error.
Regards,
Alexander Valchev
Telerik
Hello Alexander.
I'm trying to reproduce the problem in a demo, but even with the same code I can't. It always works. The only thing that comes to my mind is that it can be a global setting or something in my application which doesn't affects the demos I created outside it. So I debugged to see what happens in the demo code, in specific the kendo.web.js file to campare with the buggy one.
I realize that inside the _process method of the buggy environment, the that._aggregate property is filled with code that isn't ours, while in the demo code the property is undefined. Printing the function in the console - in the moment that a breakpoint is inside the _proccess function -, I have the output of the screenshot in the img4.png attached file.
I'm attaching the demo I've made(kendo bug.zip), which works, but is the closest I can get of my buggy environment. Note that the version of the kendo.web file in the demo is 2015.2.827 but the problem also occurs in the newer version.
I wonder what creates that aggregate function that causes the bug, that is what crashing my app. The libraries that wraps the kendo widget in the demo are the same in the buggy app and it generates the same dataSource too, no different options are set.
Thank you in advance.
The only thing that I can suggest is to start removing parts of the code in the buggy environment until you find out which part causes the error. Check if something does not change the Kendo UI widget prototypes or if something does not change the configuration objects.
If there are any 3rd party libraries in the buggy environment you should isolate and remove them during the debug process.
Regards,
Alexander Valchev
Telerik
The errors still occurs when I run this code:
$("#layers").kendoTreeView(
{
dataSource: new kendo.data.HierarchicalDataSource(
{
transport:
{
read:
{
url: "@this.TreeViewUrl("Layer/GetProductionUnits")"
}
},
dataTextField: "Text",
schema:
{
model:
{
id: "Value",
hasChildren: "HasChildren"
}
}
})
});
As you can see, it is only and pure kendo code. What I'm trying to say is that my app may have something *outside*, global, I don't know, which is causing this. I'm trying to figure out what it can be. What can add an *aggregate* method in the widget even if I don't set anything like that. I'm afraid I will have to open a ticket for this issue.
I believe I have fixed it, but I had to get rid of the HierarchicalDataSource. I changed to a simpe dataSource object. I don't know why it stop working since it is a 2+ year old code used all around the application.
This issue came along with an issue in the DropDownList, in which when user chooses an option, the selected value becomes [object Object]. This is an another old code used in all application that sudenly stop working too. Sometimes we are afraid to update the kendo version.
I have attached an example of how the DropDownList behaves now.
These are the parameters we use to initialize it:
{
dataValueField: "Value",
dataTextField: "Text",
optionLabel: { Value: "", Text: "" },
template: kendo.template("#if (data && data.Text) {#${data.Text}#}# "),
dataSource: {
type: "json",
serverFiltering: true,
transport: {
read: {
dataType: "json",
url: dropDownUrl,
type: "POST",
contentType: "application/json; charset=utf-8"
},
parameterMap: function (options) {
return JSON.stringify(options);
}
},
schema: {
data: function (data) {
if ($.isArray(data)) return data;
else return [data];
}
},
error: function (e) {
handleRequestError(e.xhr.status);
}
,
requestStart: function (e) {
thisEl.data("kendoDropDownList").select(0);
}
}
};
And this the data applied to the image example I've posted:
[{"Value":1,"Text":"Administrativo","Code":null,"LogData":null,"Parameters":null}]
Any idea on this issue?
Hello Fernando,
I've used the code snippet as a strarting point to replicate the described behavior and only mocked the jQuery.ajax call. Unfortunately I wasn't able to replicate it.
Here is the example - http://dojo.telerik.com/@rusev/oHEYe. Could you please modify it so that it replicates the issue? Thus we'll be able to debug it locally and assist you further.
Regards,
Nikolay Rusev
Telerik