11-25-2013, 06:25 PM
あるセルに入力された金額の消費税額を、同じレコードの消費税費カラムのセルに表示したいです。
下記のコードでは、常に、「最初にフォーカスを入れたセルのレコード」の消費税フィールドに
値が設定されてしまいます。
なぜでしょうか。
下記のコードでは、常に、「最初にフォーカスを入れたセルのレコード」の消費税フィールドに
値が設定されてしまいます。
なぜでしょうか。
Code:
{define-class public CustomCell {inherits StandardStringCell }
{constructor public {default ...}
{construct-super {splice ...}}
}
{method public {create-editor}:TextField
def tf = {super.create-editor}
{tf.add-event-handler
{on ValueFinished do
def yen = {String tf.value}
{if-non-null r = self.record , col = self.column then
set r["tax"] = {yen.to-int} * 0.05 & "円"
}
}
}
{return tf}
}
}
{define-class public CustomColumn {inherits RecordGridColumn}
{constructor public {default ...}
{construct-super {splice ...}}
set self.cell-spec = CustomCell
}
}
{let rs:RecordSet =
{RecordSet
{RecordFields
{RecordField "yen", domain = String, nullable? = true, caption = "価格"},
{RecordField "tax", domain = String, nullable? = true, caption = "消費税"}
},
{RecordData}, {RecordData}, {RecordData}, {RecordData}
}
}
{value
{RecordGrid
record-source = rs,
{CustomColumn "yen"}
}
}