Добрый день!
Подскажите, пожалуйста, где я мог ошибиться? При изменении зависимых полей не изменяется значение вычисляемого поля.
При инициализации метод-обработчик вызывается, а вот при измении полей "Amount" или "Budget" - нет.
define("OpportunityPageV2", [], function() {
return {
entitySchemaName: "Opportunity",
attributes: {
"UsrBudgetRemains": {
dataValueType: Terrasoft.DataValueType.FLOAT,
dependencies: [
{
colums: ["Amount", "Budget"],
methodName: "calculateBudgetRemains"
}
]
}
},
modules: /**SCHEMA_MODULES*/{}/**SCHEMA_MODULES*/,
details: /**SCHEMA_DETAILS*/{}/**SCHEMA_DETAILS*/,
businessRules: /**SCHEMA_BUSINESS_RULES*/{}/**SCHEMA_BUSINESS_RULES*/,
methods: {
onEntityInitialized: function(){
this.callParent(arguments);
this.calculateBudgetRemains();
},
calculateBudgetRemains: function() {
window.console.log("Вызвано");
var amount = this.get("Amount");
if(!amount){
amount = 0.00;
}
var budget = this.get("Budget");
if(!budget) {
this.budget = 0.00;
}
var result = budget - amount;
this.set("UsrBudgetRemains", result);
},
validateAmount: function() {
var invalidMessage = "";
if(this.get("Budget") < this.get("Amount")) {
invalidMessage = this.get("Resources.Strings.BudgetLessDueAmount");
}
return {
invalidMessage: invalidMessage
};
},
setValidationConfig: function() {
this.callParent(arguments);
this.addColumnValidator("Amount", this.validateAmount);
this.addColumnValidator("Budget", this.validateAmount);
}
},
dataModels: /**SCHEMA_DATA_MODELS*/{}/**SCHEMA_DATA_MODELS*/,
diff: /**SCHEMA_DIFF*/[
{
"operation": "insert",
"name": "UsrBudgetRemains",
"values": {
"layout": {
"colSpan": 12,
"rowSpan": 1,
"column": 0,
"row": 8,
"layoutName": "OpportunityPageGeneralBlock"
},
"bindTo": "UsrBudgetRemains",
"enabled": false
},
"parentName": "OpportunityPageGeneralBlock",
"propertyName": "items",
"index": 12
},
{
"operation": "insert",
"name": "Stage72a7f6b5-3408-4a96-be11-9928b1302433",
"values": {
"layout": {
"colSpan": 12,
"rowSpan": 1,
"column": 12,
"row": 8,
"layoutName": "OpportunityPageGeneralBlock"
},
"bindTo": "Stage"
},
"parentName": "OpportunityPageGeneralBlock",
"propertyName": "items",
"index": 13
}
]/**SCHEMA_DIFF*/
};
});