绑定后,Knockout.js失去了可观察量

时间:2015-11-04 12:32:46

标签: javascript json knockout.js signalr devextreme

我的Knockout脚本遇到了一个非常奇怪的问题。这是我的viewModel:

viewModel = {
    viewShown: function () {
        if (params.id !== undefined)
            timer = setInterval(loadVorgangsdetails, 100);
        else {
            $('#content').hide();
            viewModel.title('Fehler: Parameter Auftrag-ID wurde nicht definiert. Abbruch!');
            console.error('Parameter Auftrag-ID wurde nicht definiert', params.id);
            viewModel.isLoading(false);
        }
    },
    title: ko.observable('Vorgangsdetails für ' + params.id),
    isLoading: ko.observable(true),
    vorgangNr: ko.observable(params.id),
    aufträge: ko.observable(),
    kommission: ko.observable(),
    kommissionAlternativ: ko.observable(),
    kunde: ko.observable(),
    verlauf: ko.observable(),
};

将数据绑定到aufträge后,所有绑定都变为未定义。这意味着,在调用viewModel.aufträge(param.Aufträge);之后,当使用F12调试器时,viewModel.kommission返回“undefined”而不是function(){...}。

function loadVorgangsdetails() {
if (myHub !== undefined && myHub.connection.state === 1) {
    clearInterval(timer);
    myHub.server.getOrderDetails(viewModel.vorgangNr()).done(function (param) {
        console.log(param);
        viewModel.aufträge(param.Aufträge);
        viewModel.kommission(param.Kommission);
        viewModel.kommissionAlternativ(param.KommissionAlternativ);
        viewModel.kunde(param.Kunde);
        viewModel.verlauf(param.Verlauf);
        viewModel.isLoading(false);
    }).fail(function (params) {
        $('#content').hide();
        viewModel.title('Fehler: Der Dienst konnte die angeforderten Daten nicht bereitstellen.');
        console.error('Parameter Auftrag-ID wurde nicht definiert', params);
        viewModel.isLoading(false);
    });
} else
    console.info('Warte auf Server …');
}

以下是来自param的数据:

{"VorgangskopfID":3621295,"Gebiet":12,"Jahr":5,"Vorgang":2748,"Kommission":"Rech","KommissionAlternativ":"Naturstein","Kunde":{"KundenNr":106796},"VorgangsNr":"12502748","Anlagedatum":"2015-07-07T11:22:00","Verlauf":[{"datum":"2015-07-07T11:22:48","taetigkeit":"Angebot erfaßt.","belegnr":null,"name":"Helmut Sluzalek","telefonnr":"*** 701-174","email":"HSluzalek@***"},{"datum":"2015-07-07T16:43:44","taetigkeit":"Warten auf Konvertierung","belegnr":null,"name":"Manfred Gottschling","telefonnr":"*** 701-189","email":"mgottschling@***"},{"datum":"2015-07-07T16:44:41","taetigkeit":"Angebot Freigabe","belegnr":null,"name":"Webdienst","telefonnr":"*** 701 405","email":"fschinzler@***"},{"datum":"2015-07-08T07:38:16","taetigkeit":"Angebotsdruck","belegnr":"AN12502748","name":"EDV-Benutzer für Listings","telefonnr":"***-701125","email":"afeuerbach@***"},{"datum":"2015-07-08T07:51:13","taetigkeit":"Angebot archiviert","belegnr":"AN00009594","name":"EDV-Benutzer für Listings","telefonnr":"***-701125","email":"afeuerbach@***"},{"datum":"2015-07-13T12:33:06","taetigkeit":"Rückfrage","belegnr":"RF587173","name":"Steffen Hornung-Klieber","telefonnr":"*** - 701 171","email":"shornung@***"},{"datum":"2015-07-13T12:33:23","taetigkeit":"Rückfrage gemailt","belegnr":"RF587173","name":"EDV-Benutzer für Listings","telefonnr":"***-701125","email":"afeuerbach@***"},{"datum":"2015-08-04T09:30:02","taetigkeit":"Rückfrage abgeschlossen","belegnr":"RF587173","name":"Andreas Hauf","telefonnr":"*** - 701 272","email":"ahauf@***"},{"datum":"2015-08-11T12:06:44","taetigkeit":"Angebot zu Auftrag","belegnr":null,"name":"Helmut Sluzalek","telefonnr":"*** 701-174","email":"HSluzalek@***"},{"datum":"2015-08-11T12:06:44","taetigkeit":"Auftrag erfaßt","belegnr":null,"name":"Helmut Sluzalek","telefonnr":"*** 701-174","email":"HSluzalek@***"},{"datum":"2015-08-12T11:52:03","taetigkeit":"AB-Freigabe","belegnr":null,"name":"Helmut Sluzalek","telefonnr":"*** 701-174","email":"HSluzalek@***"},{"datum":"2015-08-13T09:30:02","taetigkeit":"Kundendienst-Schreiben","belegnr":"KS1_3809381","name":"EDV-Benutzer für Listings","telefonnr":"***-701125","email":"afeuerbach@***"},{"datum":"2015-08-13T09:30:05","taetigkeit":"Kundendienst-Schreiben","belegnr":"KS2_3809381","name":"EDV-Benutzer für Listings","telefonnr":"***-701125","email":"afeuerbach@***"},{"datum":"2015-08-13T09:30:08","taetigkeit":"Kundendienst-Schreiben","belegnr":"KS3_3809381","name":"EDV-Benutzer für Listings","telefonnr":"***-701125","email":"afeuerbach@***"},{"datum":"2015-10-09T14:08:52","taetigkeit":"Kundendienst-Schreiben","belegnr":"KS4_3809381","name":"EDV-Benutzer für Listings","telefonnr":"***-701125","email":"afeuerbach@***"},{"datum":"2015-10-09T14:08:54","taetigkeit":"Kundendienst-Schreiben","belegnr":"KS5_3809381","name":"EDV-Benutzer für Listings","telefonnr":"***-701125","email":"afeuerbach@***"},{"datum":"2015-10-20T09:52:45","taetigkeit":"Auftrag in Erfassung zurückgesetzt","belegnr":null,"name":"Helmut Sluzalek","telefonnr":"*** 701-174","email":"HSluzalek@***"},{"datum":"2015-10-20T16:03:29","taetigkeit":"Übergabe an TAB","belegnr":null,"name":"Manfred Gottschling","telefonnr":"*** 701-189","email":"mgottschling@***"},{"datum":"2015-10-21T08:21:11","taetigkeit":"AB-Freigabe","belegnr":null,"name":"Webdienst","telefonnr":"*** 701 405","email":"fschinzler@***"},{"datum":"2015-10-21T08:55:08","taetigkeit":"AN/AB per Mail verschickt","belegnr":"AB12502748","name":"EDV-Benutzer für Listings","telefonnr":"***-701125","email":"afeuerbach@***"},{"datum":"2015-10-21T08:55:11","taetigkeit":"Auftragsbestätigung","belegnr":"AB12502748","name":"EDV-Benutzer für Listings","telefonnr":"***-701125","email":"afeuerbach@***"},{"datum":"2015-10-21T11:09:27","taetigkeit":"Entahme-Etiketten gedruckt","belegnr":"EE000016303","name":"Boris Marincic","telefonnr":"*** - 701 234","email":"BMarincic@***"},{"datum":"2015-10-22T07:39:06","taetigkeit":"Kundendienst-Schreiben","belegnr":"KS6_3809381","name":"EDV-Benutzer für Listings","telefonnr":"***-701125","email":"afeuerbach@***"},{"datum":"2015-10-24T09:47:12","taetigkeit":"Kundendienst-Schreiben","belegnr":"KS7_3809381","name":"EDV-Benutzer für Listings","telefonnr":"***-701125","email":"afeuerbach@***"},{"datum":"2015-10-24T09:47:14","taetigkeit":"Kundendienst-Schreiben","belegnr":"KS8_3809381","name":"EDV-Benutzer für Listings","telefonnr":"***-701125","email":"afeuerbach@***"}],"Aufträge":[{"AuftragID":3809381,"Kommission":"Rech                ","Anlagedatum":"2015-08-11T12:06:36","Bestellnummer":"Naturstein          ","Bestelldatum":"2015-08-11T00:00:00","Besteller":"Herr Franke                     ","Abholung":false,"Versandart":"16","Tour":804,"Werkstücke":{"1":{"Position":1,"BdeDetails":[{"Machine_Id":810400,"Loading":0,"Employee":0,"Status":1,"StartTime":"0001-01-01T00:00:00","EndTime":"0001-01-01T00:00:00","Minutes_Processed":0,"Minutes_Estimated":4.3},{"Machine_Id":830100,"Loading":0,"Employee":0,"Status":4,"StartTime":"2015-10-23T11:31:36.52","EndTime":"2015-10-23T11:33:38.17","Minutes_Processed":2,"Minutes_Estimated":1.3},{"Machine_Id":830101,"Loading":0,"Employee":0,"Status":4,"StartTime":"2015-10-23T11:43:43.61","EndTime":"2015-10-23T11:45:57.35","Minutes_Processed":2.2,"Minutes_Estimated":1.3},{"Machine_Id":830102,"Loading":0,"Employee":0,"Status":4,"StartTime":"2015-10-23T12:49:21.577","EndTime":"2015-10-23T12:53:34.977","Minutes_Processed":4.2,"Minutes_Estimated":1.3},{"Machine_Id":820500,"Loading":0,"Employee":0,"Status":0,"StartTime":"0001-01-01T00:00:00","EndTime":"0001-01-01T00:00:00","Minutes_Processed":0,"Minutes_Estimated":2.8},{"Machine_Id":840200,"Loading":0,"Employee":0,"Status":4,"StartTime":"2015-10-24T08:18:33.443","EndTime":"2015-10-24T08:18:53.723","Minutes_Processed":0,"Minutes_Estimated":25.4},{"Machine_Id":860100,"Loading":0,"Employee":0,"Status":3,"StartTime":"2015-11-03T09:07:12.287","EndTime":"0001-01-01T00:00:00","Minutes_Processed":0,"Minutes_Estimated":1.3},{"Machine_Id":880100,"Loading":0,"Employee":0,"Status":4,"StartTime":"2015-11-03T14:07:19.18","EndTime":"2015-11-03T14:15:07.6","Minutes_Processed":0.9,"Minutes_Estimated":1.3},{"Machine_Id":880200,"Loading":0,"Employee":0,"Status":4,"StartTime":"2015-11-03T15:56:21.083","EndTime":"2015-11-03T15:59:53.373","Minutes_Processed":3.5,"Minutes_Estimated":1.3},{"Machine_Id":880300,"Loading":0,"Employee":0,"Status":4,"StartTime":"2015-11-03T16:09:04.637","EndTime":"2015-11-03T16:09:06.4","Minutes_Processed":0,"Minutes_Estimated":1.3}]},"2":{"Position":2,"BdeDetails":[{"Machine_Id":810400,"Loading":0,"Employee":0,"Status":4,"StartTime":"2015-11-02T11:25:50.58","EndTime":"2015-11-02T11:42:42.623","Minutes_Processed":16.8,"Minutes_Estimated":3.6},{"Machine_Id":830100,"Loading":0,"Employee":0,"Status":4,"StartTime":"2015-11-02T12:46:26.127","EndTime":"2015-11-02T12:48:38.573","Minutes_Processed":2.2,"Minutes_Estimated":1.3},{"Machine_Id":830101,"Loading":0,"Employee":0,"Status":4,"StartTime":"2015-11-02T12:49:24.593","EndTime":"2015-11-02T12:51:17.367","Minutes_Processed":1.8,"Minutes_Estimated":1.3},{"Machine_Id":820500,"Loading":0,"Employee":0,"Status":0,"StartTime":"0001-01-01T00:00:00","EndTime":"0001-01-01T00:00:00","Minutes_Processed":0,"Minutes_Estimated":2.9},{"Machine_Id":820500,"Loading":1,"Employee":0,"Status":0,"StartTime":"0001-01-01T00:00:00","EndTime":"0001-01-01T00:00:00","Minutes_Processed":0,"Minutes_Estimated":2.9},{"Machine_Id":860100,"Loading":0,"Employee":0,"Status":3,"StartTime":"2015-11-03T09:07:12.287","EndTime":"0001-01-01T00:00:00","Minutes_Processed":0,"Minutes_Estimated":1.3},{"Machine_Id":880100,"Loading":0,"Employee":0,"Status":4,"StartTime":"2015-11-03T14:07:19.18","EndTime":"2015-11-03T14:15:07.693","Minutes_Processed":0.9,"Minutes_Estimated":1.3},{"Machine_Id":880200,"Loading":0,"Employee":0,"Status":4,"StartTime":"2015-11-03T16:00:00.973","EndTime":"2015-11-03T16:09:19.94","Minutes_Processed":9.3,"Minutes_Estimated":1.3},{"Machine_Id":880300,"Loading":0,"Employee":0,"Status":4,"StartTime":"2015-11-03T16:13:57.26","EndTime":"2015-11-03T16:14:02.987","Minutes_Processed":0.1,"Minutes_Estimated":1.3},{"Machine_Id":840200,"Loading":0,"Employee":0,"Status":1,"StartTime":"0001-01-01T00:00:00","EndTime":"0001-01-01T00:00:00","Minutes_Processed":0,"Minutes_Estimated":7.7}]},"3":{"Position":3,"BdeDetails":[{"Machine_Id":810400,"Loading":0,"Employee":0,"Status":1,"StartTime":"0001-01-01T00:00:00","EndTime":"0001-01-01T00:00:00","Minutes_Processed":0,"Minutes_Estimated":5.1},{"Machine_Id":830100,"Loading":0,"Employee":0,"Status":4,"StartTime":"2015-10-23T14:01:29.473","EndTime":"2015-10-23T14:03:51.963","Minutes_Processed":2.3,"Minutes_Estimated":1.3},{"Machine_Id":830101,"Loading":0,"Employee":0,"Status":4,"StartTime":"2015-10-23T14:07:09.273","EndTime":"2015-10-23T14:21:40.417","Minutes_Processed":14.5,"Minutes_Estimated":1.3},{"Machine_Id":830102,"Loading":0,"Employee":0,"Status":4,"StartTime":"2015-10-23T14:23:06.667","EndTime":"2015-10-23T14:23:26.947","Minutes_Processed":0.3,"Minutes_Estimated":1.3},{"Machine_Id":820500,"Loading":0,"Employee":0,"Status":0,"StartTime":"0001-01-01T00:00:00","EndTime":"0001-01-01T00:00:00","Minutes_Processed":0,"Minutes_Estimated":6.8},{"Machine_Id":840300,"Loading":0,"Employee":0,"Status":4,"StartTime":"2015-10-28T14:28:15.073","EndTime":"2015-10-28T14:34:01.037","Minutes_Processed":6,"Minutes_Estimated":1.3},{"Machine_Id":860100,"Loading":0,"Employee":0,"Status":3,"StartTime":"2015-11-03T09:07:12.287","EndTime":"0001-01-01T00:00:00","Minutes_Processed":0,"Minutes_Estimated":1.3},{"Machine_Id":880100,"Loading":0,"Employee":0,"Status":4,"StartTime":"2015-11-03T14:07:19.18","EndTime":"2015-11-03T14:15:07.74","Minutes_Processed":0.9,"Minutes_Estimated":1.3},{"Machine_Id":880200,"Loading":0,"Employee":0,"Status":4,"StartTime":"2015-11-03T15:50:23.93","EndTime":"2015-11-03T15:56:16.513","Minutes_Processed":5.9,"Minutes_Estimated":1.3},{"Machine_Id":880300,"Loading":0,"Employee":0,"Status":4,"StartTime":"2015-11-03T16:05:40.09","EndTime":"2015-11-03T16:05:43.037","Minutes_Processed":0,"Minutes_Estimated":1.3}]},"4":{"Position":4,"BdeDetails":[{"Machine_Id":810400,"Loading":0,"Employee":0,"Status":0,"StartTime":"0001-01-01T00:00:00","EndTime":"0001-01-01T00:00:00","Minutes_Processed":0,"Minutes_Estimated":2.9},{"Machine_Id":830100,"Loading":0,"Employee":0,"Status":0,"StartTime":"0001-01-01T00:00:00","EndTime":"0001-01-01T00:00:00","Minutes_Processed":0,"Minutes_Estimated":1.3},{"Machine_Id":830101,"Loading":0,"Employee":0,"Status":0,"StartTime":"0001-01-01T00:00:00","EndTime":"0001-01-01T00:00:00","Minutes_Processed":0,"Minutes_Estimated":1.3},{"Machine_Id":820500,"Loading":0,"Employee":0,"Status":0,"StartTime":"0001-01-01T00:00:00","EndTime":"0001-01-01T00:00:00","Minutes_Processed":0,"Minutes_Estimated":1.3},{"Machine_Id":860100,"Loading":0,"Employee":0,"Status":3,"StartTime":"2015-11-03T09:07:12.287","EndTime":"0001-01-01T00:00:00","Minutes_Processed":0,"Minutes_Estimated":1.3},{"Machine_Id":880100,"Loading":0,"Employee":0,"Status":4,"StartTime":"2015-11-03T14:07:19.18","EndTime":"2015-11-03T14:15:07.803","Minutes_Processed":0.9,"Minutes_Estimated":1.3},{"Machine_Id":880200,"Loading":0,"Employee":0,"Status":4,"StartTime":"2015-11-03T15:12:16.793","EndTime":"2015-11-03T15:31:21.74","Minutes_Processed":19.1,"Minutes_Estimated":1.3},{"Machine_Id":880300,"Loading":0,"Employee":0,"Status":4,"StartTime":"2015-11-03T15:31:31.457","EndTime":"2015-11-03T15:31:32.473","Minutes_Processed":0,"Minutes_Estimated":1.3}]},"5":{"Position":5,"BdeDetails":[{"Machine_Id":810400,"Loading":0,"Employee":0,"Status":0,"StartTime":"0001-01-01T00:00:00","EndTime":"0001-01-01T00:00:00","Minutes_Processed":0,"Minutes_Estimated":2.9},{"Machine_Id":830100,"Loading":0,"Employee":0,"Status":0,"StartTime":"0001-01-01T00:00:00","EndTime":"0001-01-01T00:00:00","Minutes_Processed":0,"Minutes_Estimated":1.3},{"Machine_Id":830101,"Loading":0,"Employee":0,"Status":0,"StartTime":"0001-01-01T00:00:00","EndTime":"0001-01-01T00:00:00","Minutes_Processed":0,"Minutes_Estimated":1.3},{"Machine_Id":820500,"Loading":0,"Employee":0,"Status":0,"StartTime":"0001-01-01T00:00:00","EndTime":"0001-01-01T00:00:00","Minutes_Processed":0,"Minutes_Estimated":1.3},{"Machine_Id":860100,"Loading":0,"Employee":0,"Status":3,"StartTime":"2015-11-03T09:07:12.287","EndTime":"0001-01-01T00:00:00","Minutes_Processed":0,"Minutes_Estimated":1.3},{"Machine_Id":880100,"Loading":0,"Employee":0,"Status":4,"StartTime":"2015-11-03T14:07:19.18","EndTime":"2015-11-03T14:15:07.85","Minutes_Processed":0.9,"Minutes_Estimated":1.3},{"Machine_Id":880200,"Loading":0,"Employee":0,"Status":4,"StartTime":"2015-11-03T15:12:11.067","EndTime":"2015-11-03T15:27:02.67","Minutes_Processed":14.9,"Minutes_Estimated":1.3},{"Machine_Id":880300,"Loading":0,"Employee":0,"Status":4,"StartTime":"2015-11-03T15:27:18.27","EndTime":"2015-11-03T15:27:21.827","Minutes_Processed":0.1,"Minutes_Estimated":1.3}]},"6":{"Position":6,"BdeDetails":[{"Machine_Id":810400,"Loading":0,"Employee":0,"Status":0,"StartTime":"0001-01-01T00:00:00","EndTime":"0001-01-01T00:00:00","Minutes_Processed":0,"Minutes_Estimated":2.6},{"Machine_Id":830100,"Loading":0,"Employee":0,"Status":0,"StartTime":"0001-01-01T00:00:00","EndTime":"0001-01-01T00:00:00","Minutes_Processed":0,"Minutes_Estimated":1.3},{"Machine_Id":830101,"Loading":0,"Employee":0,"Status":0,"StartTime":"0001-01-01T00:00:00","EndTime":"0001-01-01T00:00:00","Minutes_Processed":0,"Minutes_Estimated":1.3},{"Machine_Id":820500,"Loading":0,"Employee":0,"Status":0,"StartTime":"0001-01-01T00:00:00","EndTime":"0001-01-01T00:00:00","Minutes_Processed":0,"Minutes_Estimated":1.3},{"Machine_Id":860100,"Loading":0,"Employee":0,"Status":3,"StartTime":"2015-11-03T09:07:12.287","EndTime":"0001-01-01T00:00:00","Minutes_Processed":0,"Minutes_Estimated":1.3},{"Machine_Id":880100,"Loading":0,"Employee":0,"Status":4,"StartTime":"2015-11-03T14:07:19.18","EndTime":"2015-11-03T14:15:07.897","Minutes_Processed":0.9,"Minutes_Estimated":1.3},{"Machine_Id":880200,"Loading":0,"Employee":0,"Status":4,"StartTime":"2015-11-03T15:11:55.827","EndTime":"2015-11-03T15:17:58.353","Minutes_Processed":6,"Minutes_Estimated":1.3},{"Machine_Id":880300,"Loading":0,"Employee":0,"Status":4,"StartTime":"2015-11-03T15:21:51.777","EndTime":"2015-11-03T15:21:56.037","Minutes_Processed":0.1,"Minutes_Estimated":1.3}]},"7":{"Position":7,"BdeDetails":[{"Machine_Id":810400,"Loading":0,"Employee":0,"Status":0,"StartTime":"0001-01-01T00:00:00","EndTime":"0001-01-01T00:00:00","Minutes_Processed":0,"Minutes_Estimated":2.4},{"Machine_Id":830100,"Loading":0,"Employee":0,"Status":0,"StartTime":"0001-01-01T00:00:00","EndTime":"0001-01-01T00:00:00","Minutes_Processed":0,"Minutes_Estimated":1.3},{"Machine_Id":830101,"Loading":0,"Employee":0,"Status":0,"StartTime":"0001-01-01T00:00:00","EndTime":"0001-01-01T00:00:00","Minutes_Processed":0,"Minutes_Estimated":1.3},{"Machine_Id":820500,"Loading":0,"Employee":0,"Status":0,"StartTime":"0001-01-01T00:00:00","EndTime":"0001-01-01T00:00:00","Minutes_Processed":0,"Minutes_Estimated":1.3},{"Machine_Id":860100,"Loading":0,"Employee":0,"Status":3,"StartTime":"2015-11-03T09:07:12.287","EndTime":"0001-01-01T00:00:00","Minutes_Processed":0,"Minutes_Estimated":1.3},{"Machine_Id":880100,"Loading":0,"Employee":0,"Status":4,"StartTime":"2015-11-03T14:07:19.18","EndTime":"2015-11-03T14:15:07.943","Minutes_Processed":0.9,"Minutes_Estimated":1.3},{"Machine_Id":880200,"Loading":0,"Employee":0,"Status":4,"StartTime":"2015-11-03T15:11:46.967","EndTime":"2015-11-03T15:12:30.85","Minutes_Processed":0.7,"Minutes_Estimated":1.3},{"Machine_Id":880300,"Loading":0,"Employee":0,"Status":4,"StartTime":"2015-11-03T15:13:46.43","EndTime":"2015-11-03T15:13:50.69","Minutes_Processed":0.1,"Minutes_Estimated":1.3}]},"8":{"Position":8,"BdeDetails":[{"Machine_Id":810400,"Loading":0,"Employee":0,"Status":0,"StartTime":"0001-01-01T00:00:00","EndTime":"0001-01-01T00:00:00","Minutes_Processed":0,"Minutes_Estimated":3.2},{"Machine_Id":830100,"Loading":0,"Employee":0,"Status":0,"StartTime":"0001-01-01T00:00:00","EndTime":"0001-01-01T00:00:00","Minutes_Processed":0,"Minutes_Estimated":1.3},{"Machine_Id":830101,"Loading":0,"Employee":0,"Status":0,"StartTime":"0001-01-01T00:00:00","EndTime":"0001-01-01T00:00:00","Minutes_Processed":0,"Minutes_Estimated":1.3},{"Machine_Id":820500,"Loading":0,"Employee":0,"Status":0,"StartTime":"0001-01-01T00:00:00","EndTime":"0001-01-01T00:00:00","Minutes_Processed":0,"Minutes_Estimated":1.3},{"Machine_Id":860100,"Loading":0,"Employee":0,"Status":3,"StartTime":"2015-11-03T09:07:12.287","EndTime":"0001-01-01T00:00:00","Minutes_Processed":0,"Minutes_Estimated":1.3},{"Machine_Id":880100,"Loading":0,"Employee":0,"Status":4,"StartTime":"2015-11-03T14:07:19.18","EndTime":"2015-11-03T14:15:08.007","Minutes_Processed":0.9,"Minutes_Estimated":1.3},{"Machine_Id":880200,"Loading":0,"Employee":0,"Status":4,"StartTime":"2015-11-03T15:11:56.467","EndTime":"2015-11-03T15:28:46.643","Minutes_Processed":16.8,"Minutes_Estimated":1.3},{"Machine_Id":880300,"Loading":0,"Employee":0,"Status":4,"StartTime":"2015-11-03T15:29:21.587","EndTime":"2015-11-03T15:29:22.617","Minutes_Processed":0,"Minutes_Estimated":1.3}]},"9":{"Position":9,"BdeDetails":null},"10":{"Position":10,"BdeDetails":null},"11":{"Position":11,"BdeDetails":null},"12":{"Position":12,"BdeDetails":null},"13":{"Position":13,"BdeDetails":null},"14":{"Position":14,"BdeDetails":null},"15":{"Position":15,"BdeDetails":null},"971":{"Position":971,"BdeDetails":null},"991":{"Position":991,"BdeDetails":null},"992":{"Position":992,"BdeDetails":null}}}]}

那里发生了什么?为什么viewModel.aufträge(param.Aufträge)失败了?如果我对该行进行注释,则可以正常工作(除了数据保持为空)。

非常感谢您提前帮助我!

祝你好运

2 个答案:

答案 0 :(得分:0)

这可能是因为您致电viewModel.aufträge(param.Aufträge)params上的财产为"aufträge",即没有首都。

答案 1 :(得分:0)

我发现了问题!我的数据来自SignalR服务器。我在服务器端使用了Dictionary(Of Int32,Werkstück)。现在看起来Knockout无法正确处理。我将它改为List(OfWerkstück),现在它可以工作了。

这是没有工作的JSON。新的没有索引号,而是一个简单的Werkstück对象数组。

"Werkstücke":{  
    "1":{  
        "Position":1,
        "BdeDetails":[  
            {  
                "Machine_Id":810400,
                "Loading":0,
                "Employee":0,
                "Status":1,
                "StartTime":"0001-01-01T00:00:00",
                "EndTime":"0001-01-01T00:00:00",
                "Minutes_Processed":0,
                "Minutes_Estimated":4.3
            },
            {  
                "Machine_Id":830100,
                "Loading":0,
                "Employee":0,
                "Status":4,
                "StartTime":"2015-10-23T11:31:36.52",
                "EndTime":"2015-10-23T11:33:38.17",
                "Minutes_Processed":2,
                "Minutes_Estimated":1.3
            },
            {  
                "Machine_Id":830101,
                "Loading":0,
                "Employee":0,
                "Status":4,
                "StartTime":"2015-10-23T11:43:43.61",
                "EndTime":"2015-10-23T11:45:57.35",
                "Minutes_Processed":2.2,
                "Minutes_Estimated":1.3
            },
            {  
                "Machine_Id":830102,
                "Loading":0,
                "Employee":0,
                "Status":4,
                "StartTime":"2015-10-23T12:49:21.577",
                "EndTime":"2015-10-23T12:53:34.977",
                "Minutes_Processed":4.2,
                "Minutes_Estimated":1.3
            },
            {  
                "Machine_Id":820500,
                "Loading":0,
                "Employee":0,
                "Status":0,
                "StartTime":"0001-01-01T00:00:00",
                "EndTime":"0001-01-01T00:00:00",
                "Minutes_Processed":0,
                "Minutes_Estimated":2.8
            },
            {  
                "Machine_Id":840200,
                "Loading":0,
                "Employee":0,
                "Status":4,
                "StartTime":"2015-10-24T08:18:33.443",
                "EndTime":"2015-10-24T08:18:53.723",
                "Minutes_Processed":0,
                "Minutes_Estimated":25.4
            },
            {  
                "Machine_Id":860100,
                "Loading":0,
                "Employee":0,
                "Status":3,
                "StartTime":"2015-11-03T09:07:12.287",
                "EndTime":"0001-01-01T00:00:00",
                "Minutes_Processed":0,
                "Minutes_Estimated":1.3
            },
            {  
                "Machine_Id":880100,
                "Loading":0,
                "Employee":0,
                "Status":4,
                "StartTime":"2015-11-03T14:07:19.18",
                "EndTime":"2015-11-03T14:15:07.6",
                "Minutes_Processed":0.9,
                "Minutes_Estimated":1.3
            },
            {  
                "Machine_Id":880200,
                "Loading":0,
                "Employee":0,
                "Status":4,
                "StartTime":"2015-11-03T15:56:21.083",
                "EndTime":"2015-11-03T15:59:53.373",
                "Minutes_Processed":3.5,
                "Minutes_Estimated":1.3
            },
            {  
                "Machine_Id":880300,
                "Loading":0,
                "Employee":0,
                "Status":4,
                "StartTime":"2015-11-03T16:09:04.637",
                "EndTime":"2015-11-03T16:09:06.4",
                "Minutes_Processed":0,
                "Minutes_Estimated":1.3
            }
        ]
        },
        "2":{  
        "Position":2,
        "BdeDetails":[  
            {  
                "Machine_Id":810400,
                "Loading":0,
                "Employee":0,
                "Status":4,
                "StartTime":"2015-11-02T11:25:50.58",
                "EndTime":"2015-11-02T11:42:42.623",
                "Minutes_Processed":16.8,
                "Minutes_Estimated":3.6
            },
            {  
                "Machine_Id":830100,
                "Loading":0,
                "Employee":0,
                "Status":4,
                "StartTime":"2015-11-02T12:46:26.127",
                "EndTime":"2015-11-02T12:48:38.573",
                "Minutes_Processed":2.2,
                "Minutes_Estimated":1.3
            },
            {  
                "Machine_Id":830101,
                "Loading":0,
                "Employee":0,
                "Status":4,
                "StartTime":"2015-11-02T12:49:24.593",
                "EndTime":"2015-11-02T12:51:17.367",
                "Minutes_Processed":1.8,
                "Minutes_Estimated":1.3
            },
            {  
                "Machine_Id":820500,
                "Loading":0,
                "Employee":0,
                "Status":0,
                "StartTime":"0001-01-01T00:00:00",
                "EndTime":"0001-01-01T00:00:00",
                "Minutes_Processed":0,
                "Minutes_Estimated":2.9
            },
            {  
                "Machine_Id":820500,
                "Loading":1,
                "Employee":0,
                "Status":0,
                "StartTime":"0001-01-01T00:00:00",
                "EndTime":"0001-01-01T00:00:00",
                "Minutes_Processed":0,
                "Minutes_Estimated":2.9
            },
            {  
                "Machine_Id":860100,
                "Loading":0,
                "Employee":0,
                "Status":3,
                "StartTime":"2015-11-03T09:07:12.287",
                "EndTime":"0001-01-01T00:00:00",
                "Minutes_Processed":0,
                "Minutes_Estimated":1.3
            },
            {  
                "Machine_Id":880100,
                "Loading":0,
                "Employee":0,
                "Status":4,
                "StartTime":"2015-11-03T14:07:19.18",
                "EndTime":"2015-11-03T14:15:07.693",
                "Minutes_Processed":0.9,
                "Minutes_Estimated":1.3
            },
            {  
                "Machine_Id":880200,
                "Loading":0,
                "Employee":0,
                "Status":4,
                "StartTime":"2015-11-03T16:00:00.973",
                "EndTime":"2015-11-03T16:09:19.94",
                "Minutes_Processed":9.3,
                "Minutes_Estimated":1.3
            },
            {  
                "Machine_Id":880300,
                "Loading":0,
                "Employee":0,
                "Status":4,
                "StartTime":"2015-11-03T16:13:57.26",
                "EndTime":"2015-11-03T16:14:02.987",
                "Minutes_Processed":0.1,
                "Minutes_Estimated":1.3
            },
            {  
                "Machine_Id":840200,
                "Loading":0,
                "Employee":0,
                "Status":1,
                "StartTime":"0001-01-01T00:00:00",
                "EndTime":"0001-01-01T00:00:00",
                "Minutes_Processed":0,
                "Minutes_Estimated":7.7
            }
        ]
    },
⋮