Code:
{curl 7.0 applet}
{let people:RecordSet =
{RecordSet
{RecordFields
{RecordField "First", domain = String},
{RecordField "Last", domain = String},
{RecordField "Age", domain = int},
|| hidden field
{RecordField "hidden", domain = int}
},
|| hidden = 0
{RecordData First = "Gene", Last = "Smith", Age = 25, hidden = 0},
{RecordData First = "Fred", Last = "Smith", Age = 29, hidden = 0},
{RecordData First = "Mike", Last = "Jones", Age = 28, hidden = 0},
{RecordData First = "Ben", Last = "Abrams", Age = 25, hidden = 0},
{RecordData First = "Ben", Last = "Smith", Age = 21, hidden = 0},
{RecordData First = "Sam", Last = "Jones", Age = 22, hidden = 0},
{RecordData First = "Nigel", Last = "Stevens", Age = 24, hidden = 0},
{RecordData First = "Bert", Last = "Stevens", Age = 22, hidden = 0},
{RecordData First = "Pat", Last = "Linden", Age = 27, hidden = 0},
|| hidden = 1
{RecordData First = "TOTAL", Last = "", Age = 25+29+28, hidden = 1}
}
}
{let asc?:bool = true}
{let last-sort-column:String = ""}
{def rg = {RecordGrid
record-source = people,
height = 10cm,
automatic-columns? = false,
{RecordGridColumn "First"},
{RecordGridColumn "Last"},
{RecordGridColumn "Age"},
sort = {RecordSort.from-string "hidden, Age"},
sort-spec = {proc {rgc:RecordGridColumn}:RecordSort
{if last-sort-column != rgc.field-name then
set asc? = true
}
let rs:RecordSort =
{RecordSort.from-string
"hidden " &
{if asc? then
"asc"
else
"desc"
}
& ", " & rgc.field-name
}
|| Store column name and sort order.
set last-sort-column = rgc.field-name
set asc? = not asc?
{return rs}
}
}
}
{value rg}