0

在问我的问题之前,我先举一个简单的例子来说明我的问题。

在我的 LightSwitch HTML 客户端中,我有一个包含一列的表格:“金额”

我创建了一个计算属性“amountPlusTax”,并将其值设置如下,

myapp.BrowseTransactions.amountPlusTax_postRender = function (element, contentItem) {
        contentItem.dataBind("data.amount", function () {
            $(element).text(parseFloat(contentItem.data.amount) * 1.05);
        });
 };

如您所见,amountPlusTax = 金额 * 1.05

我遇到的问题我想创建另一个计算属性,其值取决于“amountPlusTax”计算属性的值。比如,amountPlusTaxPlusInterest = amountPlusTax * 1.03

这怎么可能?

这不起作用:

myapp.BrowseTransactions.amountPlusTaxPlusInterest_postRender = function (element, contentItem) {
    $(element).text(parseFloat(contentItem.screen.amountPlusTax) * 1.03);
};
4

1 回答 1

0

Although this doesn't directly answer your question, you could alternatively capture the Inserting/Inserted/Updating/Updated events in the DataService and update one or both of the fields instead of using computed properties.

For example:

partial void SomeTable_Updating(SomeTable entity)
    {
        if (entity.SomeField.IsNullOrWhiteSpace())
            entity.SomeField = Utils.ConvertToValidName(entity.Name);
    }
于 2015-04-23T02:38:48.300 回答