This is a migrated thread and some comments may be shown as answers.

Uncaught TypeError: Cannot read property 'data' of undefined

1 Answer 1045 Views
ListView
This is a migrated thread and some comments may be shown as answers.
Ton
Top achievements
Rank 1
Ton asked on 02 Sep 2020, 03:23 PM

Hi all,

I have a listView with the following bindings:

listView.bind("remove", function(e) {
 
$.ajax({
type : "POST",
url : vulnerabilityAssessment.deleteVulnerabilityAssessmentItem.replace("{itemId}", e.model.id),
contentType : 'application/json',
dataType : "json",
success : function(response) {
refreshCurrentListView(listViewId, scope);
},
});
 
}
 
 
listView.bind("save", function(e) {
 
var item = {
id: ...,
vulnerabilityAssessment: vulnerabilityAssessmentId,
.....
}
if(e.model.id == null)
item.id = -1;
 
$.ajax({
type : "POST",
url : vulnerabilityAssessment.saveVulnerabilityAssessmentItem,
contentType : 'application/json',
data : JSON.stringify(item),
complete : function(e) {
refreshCurrentListView(listViewId, scope);
},
error : function(e) {
showErrorDialog(e);
},
dataType : "json"
});
});

 

And the refreshCurrentListView function as follows:

function refreshCurrentListView(listViewId, scope) {
    var type = parseInt(listViewId.substr(listViewId.indexOf("_") + 1));
    var vulnerabilityAssessmentId = $("#vulnerabilityCurrentAssessmentListView", scope).children('div').children('div')[0].id.substr($("#vulnerabilityCurrentAssessmentListView", scope).children('div').children('div')[0].id.indexOf("_") + 1);
    if(listViewId.includes("Strenght")) {
        var itemViewModel = itemViewStrength(vulnerabilityAssessmentId, type, 'S');
         
        kendo.bind  ($("#threatCurrentVulnerabilityAssessment #" + listViewId, scope), itemViewModel);
         
        $("#threatStrenghtListView_" + type + " .edit-buttons").show();
    }
}

 

I'm adding a new record on the list and as soon as I add a second row , I get the following exception:

Uncaught TypeError: Cannot read property 'data' of undefined
    at init.setup (kendo.all.min.js:27)
    at init.create (kendo.all.min.js:27)
    at Object.<anonymous> (kendo.all.min.js:27)
    at Function.Deferred (jquery.min.js:2)
    at init._promise (kendo.all.min.js:27)
    at init._send (kendo.all.min.js:27)
    at init.sync (kendo.all.min.js:27)
    at init.save (kendo.all.min.js:54)
    at HTMLAnchorElement.<anonymous> (kendo.all.min.js:54)
    at HTMLDivElement.dispatch (jquery.min.js:3)

 

This exception happens when the ajax call inside the 'save' binding takes place (and before it gets to the complete function).

Any ideas?

1 Answer, 1 is accepted

Sort by
0
Georgi
Telerik team
answered on 04 Sep 2020, 10:34 AM

Hello Ton,

I have examined the provided snippets and I don't see anything that might cause the issue. Would it be possible to assemble a small dojo sample where the issue can be replicated? 

Thanks in advance.

Regards,
Georgi
Progress Telerik

Virtual Classroom, the free self-paced technical training that gets you up to speed with Telerik and Kendo UI products quickly just got a fresh new look + new and improved content including a brand new Blazor course! Check it out at https://learn.telerik.com/.

Tags
ListView
Asked by
Ton
Top achievements
Rank 1
Answers by
Georgi
Telerik team
Share this question
or