Jquery 使用共享点列表和库强制保存灯光开关形式的更改(第二屏并在第一屏上反映)
我在Light switch HTML应用程序(Visual C#)中创建了一个表单 这是表格: 它从三个字段计算预算。其中之一是从另一个屏幕获取价值的总额(通过单击“插入项目”,可以添加具有各自金额的新项目) 这些将保存在小计(屏幕一项)中。其他两个字段是意外因素和金额,可以添加以对金额进行四舍五入。 然后,所有这三个字段的合计必须保存在第四个字段中,即合计金额 现在我面临的问题是:Jquery 使用共享点列表和库强制保存灯光开关形式的更改(第二屏并在第一屏上反映),jquery,html,sharepoint-2013,lightswitch-2013,Jquery,Html,Sharepoint 2013,Lightswitch 2013,我在Light switch HTML应用程序(Visual C#)中创建了一个表单 这是表格: 它从三个字段计算预算。其中之一是从另一个屏幕获取价值的总额(通过单击“插入项目”,可以添加具有各自金额的新项目) 这些将保存在小计(屏幕一项)中。其他两个字段是意外因素和金额,可以添加以对金额进行四舍五入。 然后,所有这三个字段的合计必须保存在第四个字段中,即合计金额 现在我面临的问题是: 当我添加项目时,它不会保存总金额,它只会在添加其他金额或连续系数时更改。如何立即反映这些价值观 Total
function calculateTotal(screen) {
try {
if ($('[id$=equipment_varSubTotal]').val() != "0") {
screen.findContentItem("CapexMain_Equipment_SubTotal").value = $('[id$=equipment_varSubTotal]').val();
var salesTax = parseFloat(screen.findContentItem("CapexMain_Equipment_SalesTax").value ? screen.findContentItem("CapexMain_Equipment_SalesTax").value : 0);
var freight = parseFloat(screen.findContentItem("CapexMain_Equipment_Freight").value ? screen.findContentItem("CapexMain_Equipment_Freight").value : 0);
var contingenceFactor = parseFloat(screen.findContentItem("CapexMain_Equipment_ContingenceFactor").value ? screen.findContentItem("CapexMain_Equipment_ContingenceFactor").value : 0);
var otherAmount = parseFloat(screen.findContentItem("CapexMain_Equipment_OtherAmount").value ? screen.findContentItem("CapexMain_Equipment_OtherAmount").value : 0);
var total = parseFloat(screen.findContentItem("CapexMain_Equipment_SubTotal").value ? screen.findContentItem("CapexMain_Equipment_SubTotal").value : $('[id$=equipment_varSubTotal]').val() ? $('[id$=equipment_varTotal]').val() : 0);
//var total = parseFloat($('[id$=equipment_varTotal]').val());
total = salesTax + freight + contingenceFactor + otherAmount + total;
if (total != 0) {
//$('[id$=equipment_varTotal]').val(total);
$('[id$=CapexMain_Equipment_TotalCapexAmount]').val(total);
screen.findContentItem("CapexMain_Equipment_TotalCapexAmount").value = total;
$('[id$=equipment_varTotal]').val(total);
}
}
}
catch (e) { }
}
myapp.AddEditCapexMain.created = function (screen) {
$('#equipment_varSubTotal').change(function () {
var a = "a";
});
screen.CapexMain.addChangeListener("Equipment_SubTotal", function (e) {
var amount = parseFloat(screen.findContentItem("CapexMain_Equipment_SubTotal").value);
if (amount > 0) {
var total = parseFloat($('[id$=equipment_varTotal]').val());
total += amount;
$('[id$=CapexMain_Equipment_TotalCapexAmount]').val(total);
}
});
screen.CapexMain.addChangeListener("Equipment_ContingenceFactor", function (e) { calculateTotal(screen);
});
screen.CapexMain.addChangeListener("Equipment_OtherAmount", function (e) {
calculateTotal(screen);
});
screen.details.rootContentItem.handleViewDispose(function () {
screen.CapexMain.removeChangeListener("Equipment_SubTotal", onPropertyChanged);
screen.CapexMain.removeChangeListener("Equipment_ContingenceFactor", onPropertyChanged);
screen.CapexMain.removeChangeListener("Equipment_OtherAmount", onPropertyChanged);
});
};
如果所有的计算都发生在jquery中,我们需要查看jquery代码以提供任何信息。网站的截图一文不值。@Jhorra Paradon,我是StackOver flow的新手。我已经添加了代码。请看一看,我想到了一些想法。确保您有有效的值,并且没有向非值添加数字,这可能会取消您的添加。另一个是确保字段名ID与函数中的匹配。您可以通过执行
警报(总计)来判断函数是否正常工作代码>完成添加后,查看实际得到的内容。如果您得到一个意外的值,它在您的函数中,如果您得到正确的值,它可能在您的字段名中。