顯示的數據我有數據從JSON來爲:淘汰賽映射插件到表
[
{"ProjectName":"Region1.Site1","Turbine":"T1","Fault":0,"Description":"No Fault"},
{"ProjectName":"Region1.Site1","Turbine":"T2","Fault":0,"Description":"No Fault"},
{"ProjectName":"Region1.Site1","Turbine":"T3","Fault":1,"Description":"In Alarm"},
{"ProjectName":"Region1.Site1","Turbine":"T4","Fault":1,"Description":"In Alarm"},
{"ProjectName":"Region1.Site2","Turbine":"T1","Fault":0,"Description":"No Fault"},
{"ProjectName":"Region1.Site2","Turbine":"T2","Fault":0,"Description":"No Fault"},
{"ProjectName":"Region1.Site2","Turbine":"T3","Fault":1,"Description":"In Alarm"},
{"ProjectName":"Region1.Site2","Turbine":"T4","Fault":1,"Description":"In Alarm"}
]
我想顯示此數據插入到表與表頭爲Project Name
,Turbine
,Fault
,Description
。
我正在使用Knockout.js和mapping plugin以及。這是一個JSFiddle to show what I tried so far。
我主要有兩個目標
- 將這個數據到表
- 更新的行每當故障狀態的變化。每行都由ProjectName和Turbine的組合唯一標識。
由於桑迪普。
我遇到了這個問題,我嘗試使用映射插件。
var viewModel = {};
viewModel.Stats = ko.mapping.fromJS(data);
能否請你告訴我什麼,我做錯了。另外,當我收到數據更新時,以下聲明是否有效?
ko.mapping.fromJS(data,viewModel);
由於映射插件沒有工作,我不得不使用ko.utils.Arraymap功能。
感謝