gpt4 book ai didi

javascript - 无法读取未定义的数据? json

转载 作者:行者123 更新时间:2023-12-03 09:43:01 25 4
gpt4 key购买 nike

这是我使用js保存值的代码

 self.Save = function (e) {

if (vm_Currencies.selectedRow.CurrencyName == null) {
alert("Fill Some Thing");
}
if (vm_Currencies.selectedRow.CurrencyCode != null) {
debugger;

var text1 = { "CurrencyCode": vm_Currencies.selectedRow.CurrencyCode, "CurrencyName": vm_Currencies.selectedRow.CurrencyName, "CurrencySign": vm_Currencies.selectedRow.CurrencySign, "DecimalPlaces": vm_Currencies.selectedRow.DecimalPlaces, "PositiveFormat": vm_Currencies.selectedRow.PositiveFormat, "NegativeFormat": vm_Currencies.selectedRow.NegativeFormat, "CurrencyStatus": vm_Currencies.selectedRow.CurrencyStatus };
self.dsProduct.add(text1);
///////////error comes here while i call sync()
self.dsProduct.sync();
////cannot read data of undefined
}
if (e.data.CurrencyName != null) {
debugger;
var text2 = { "CurrencyName": e.data.CurrencyName, "CurrencySign": e.data.CurrencySign, "DecimalPlaces": e.data.DecimalPlaces, "PositiveFormat": e.data.PositiveFormat, "NegativeFormat": e.data.NegativeFormat, "CurrencyStatus": e.data.CurrencyStatus };
self.dsProduct.add(text2);
/////////sucess
self.dsProduct.sync();
/////sucess
}

}

当我在调试期间将值发送到顶部 Controller 以保存时,text2 有效,但 text1 不起作用我检查格式两者的格式是否相同,我应该如何同步这些值,以便服务器端接收它们进行更新

这是控制台调试中 text1 和 text2 的格式

   CurrencyCode: 20
CurrencyName: "dollar"
CurrencySign: "$"
CurrencyStatus: "23"
DecimalPlaces: 1
NegativeFormat: "12"
PositiveFormat: "12"
__proto__: Object

最佳答案

       self.Save = function (e) {
debugger;
if (vm_Currencies.selectedRow.CurrencyCode == null)
{
var GetValuesForSaving = { "CurrencyName": e.data.CurrencyName, "CurrencySign": e.data.CurrencySign, "DecimalPlaces": e.data.DecimalPlaces, "PositiveFormat": e.data.PositiveFormat, "NegativeFormat": e.data.NegativeFormat, "CurrencyStatus": e.data.CurrencyStatus };
self.dsProduct.add(GetValuesForSaving);
self.dsProduct.sync();
}

else
{
debugger;
var GetValuesForSaving = { "CurrencyC": vm_Currencies.selectedRow.CurrencyCode, "CurrencyName": vm_Currencies.selectedRow.CurrencyName, "CurrencySign": vm_Currencies.selectedRow.CurrencySign, "DecimalPlaces": vm_Currencies.selectedRow.DecimalPlaces, "PositiveFormat": vm_Currencies.selectedRow.PositiveFormat, "NegativeFormat": vm_Currencies.selectedRow.NegativeFormat, "CurrencyStatus": vm_Currencies.selectedRow.CurrencyStatus };
self.dsProduct.add(GetValuesForSaving);
self.dsProduct.sync();
}

}

关于javascript - 无法读取未定义的数据? json,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/31130705/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com