最上行に表示するのであれば、ソートや行列の固定を利用(オーバーライドも必要?)すれば、何とか実装できそうな気がしていますが、
最下行として表示する方法についてはうまく思いつきません。
(最下行のレコードを対象に行列の固定をすると、スクロールできなくなってしまうため)
エクセルなどでも、合計行は、通常、下の方に表示することが多いと思いますが
Curl を利用した業務画面では、どのようなレイアウト実装をすることが多いのでしょうか。
Code:
{value
def rfs =
{RecordFields
{RecordField "sum?", modifiable? = false, domain = bool, default-value = false},
{RecordField "title", domain = String, caption = "項目"},
{RecordField "1", domain = String, caption = "1月"},
{RecordField "2", domain = String, caption = "2月"},
{RecordField "3", domain = String, caption = "3月"},
{RecordField "4", domain = String, caption = "4月"},
{RecordField "5", domain = String, caption = "5月"},
{RecordField "6", domain = String, caption = "6月"},
{RecordField "7", domain = String, caption = "7月"},
{RecordField "8", domain = String, caption = "8月"},
{RecordField "9", domain = String, caption = "9月"},
{RecordField "10", domain = String, caption = "10月"},
{RecordField "11", domain = String, caption = "11月"},
{RecordField "12", domain = String, caption = "12月"}
}
let rs:RecordSet = {RecordSet rfs }
def rg = {RecordGrid width = 5in}
set rg.record-source = rs
{for i:int = 0 to 50 do
def r1 = {rs.new-record}
{rs.append r1}
}
||合計計算
{rs.add-event-handler
{on e:RecordModified do
{if-non-null rf = e.field then
{if rf.name != "sum?" then
let sum:int = 0
{for r in rs do
{if r["sum?"] != true then
def s = {String r[rf.name] }
set sum = sum + {s.to-int}
}
}
{if-non-null sum-r =
{rs.select-one
filter =
{RecordFilter
{proc {r:Record}:bool
{if r["sum?"] == true then
{return true}
}
{return false}
}
}
} then
set sum-r[rf.name] = {String sum}
}
}
}
}
}
||合計行を最上行として表示
def r = {rs.new-record}
set r["sum?"] = true
{rs.append r}
{rs.commit}
set rg.frozen-row-count = 1
set rg.sort = "sum?"
||合計行を入力不可にする
def sum-r-idx:int = 0
{for col:int = 0 below rg.columns.size do
{if-non-null cell = {rg.ui.get-cell-at-index sum-r-idx, col} then
set cell.editable? = false
}
}
rg
}