2016-05-16 12 views
0

Ich versuche, ein Element in meinen Kendo DataSource hinzufügen, aber ich erhalte die folgende Fehlermeldung, wenn ich versuche und füge:Kendo dataSource.add - Fehlertyp: o undefiniert

TypeError: o is undefined - kendo.all.min.js (line 50, col 23446)

Dies geschieht, wenn ich versuche, und verwenden Sie die dataSource.add() Methode.

sectionNotesDataSource: new kendo.data.DataSource({ 
    transport: { 
     read: { 
      url: "/baa/baa/GetNotes", 
      dataType: "json", 
      type: "GET", 
      data: { 
       Id: $("#Id").val() 
      } 
     }, 
     create: { 
      url: "/baa/baa/CreateNote", 
      dataType: "json", 
      type: "POST" 
     }, 
     parameterMap: function (data, operation) { 
      if (operation === "update" || operation === "create") { 
       data.CreateDate = _dateToString(data.CreateDate); 
       data.LastModDate = _dateToString(data.LastModDate); 
      } 
      return data; 
     } 
    }, 
    schema: { 
     model: { 
      id: "Id", 
      fields: { 
       Id: { type: "number", editable: false, nullable: true }, 
       BaaId: { type: "number", editable: false, nullable: false }, 
       BaaSectionId: { type: "number", editable: false, nullable: false }, 
       Body: { type: "string", editable: true }, 
      } 
     } 
    } 
}), 
onNewNote: function (e) { 
    var baaId = $(e.currentTarget).data("baaId"); 
    var baaSectionId = $(e.currentTarget).data("baasection"); 
    var noteList = $(e.target).closest(".baa-section-notes").find(".section-note-list").data("kendoListView"); 

    $("#NoteSave").on("click", function() { 
     var body = editor.value(); 
     noteList.add({ BaaId: baaId, BaaSectionId: baaSectionId, Body: body }); 
} 
}); 

Ich habe versucht, diesen Fehler, um herauszufinden, was für die letzten paar Stunden verursacht, aber kann einfach nicht scheinen, um es herauszufinden.

BaaId, BaaSectionId und Body alle enthalten Werte, so dass ich vollständig auf diesen Bug verloren bin.

Antwort

0

Ich endete mein Problem zu lösen.

änderte ich die Linie

noteList.add({ BaaId: baaId, BaaSectionId: baaSectionId, Body: body }); 

zu

noteList.dataSource.add({ BaaId: baaId, BaaSectionId: baaSectionId, Body: body });