我有可读写的总计算输入框。计算写入不适用于阵列
<div data-bind="foreach:TotalCostQuantity">
<input data-bind:"value: Cost, valueUpdate:'afterkeydown'" /><br />
<input data-bind:"value: Quantity, valueUpdate:'afterkeydown'" />
</div>
我的视图模型是这样的:
self.TrancheCostQuantity = ko.computed({
read: function() {
//do some math here to calculate cost and quant totals
return [{Cost:100, Quantity:10},{Cost:200, Quantity:20}];
},
write: function (newValue) {
customformat(newValue);
}
}, self);
的成本和数量都从能有行和列的动态数量的网格。它使用ko.mapping插件进行映射。
我需要写入,但它从来没有。阅读工作正常,但我无法验证或自定义格式我的写道。
你能不能做一个小提琴? – Damien
'customformat'函数的作用是什么? –
customformat将使TrancheCostQuantity向上舍入到最近的美元并添加一个美元符号。 – user1175857