I think the best way to do this is to not use the built in record selection mechanism at all. Instead, use a boolean field in each record to indicate if the record is selected. Use a custom column header to get the select-all checkbutton at the top, and use a row-background-spec procedure to colorize the selected records. Here is some sample code:
{curl 6.0, 7.0 applet}
{title Checkbox in Header}
{import * from CURL.DATA-ACCESS.BASE}
{let dataset:RecordSet =
{RecordSet
{RecordFields
{RecordField "id",
caption = "ID", domain = int,
index-type = RecordFieldIndexType.unique
},
{RecordField "Title", domain = String},
{RecordField "Date", domain = {StandardDateDomain}},
{RecordField "selected", caption = "\u221a", domain = bool}
},
{RecordData id = 1, Title = "Meeting Friday", Date = "2007-12-15"},
{RecordData id = 2, Title = "Re: Meeting Friday", Date = "2007-12-16"},
{RecordData id = 3, Title = "Re: Meeting Friday", Date = "2007-12-16"},
{RecordData id = 4,
Title = "Need your help (financial transaction)",
Date = "2008-04-01"
},
{RecordData id = 5, Title = "Good news", Date = "2008-05-05"}
}
}
{let select-all-ctrl:CheckButton =
{CheckButton
label = "",
{on ValueChanged at cb:CheckButton do
{with rg.records.batch-events? = true do
{for r:Record key ri:int in rg.records do
set r["selected"] = cb.value
}
}
}
}
}
{let rg:RecordGrid =
{RecordGrid
width = 5in, height = 3in,
background = "#f0f0f0",
display-filler-column? = true,
display-record-selectors? = false,
display-navigation-panel? = false,
record-source = dataset,
editable? = true,
select-current-record? = false,
row-background-spec =
{proc {rg:RecordGrid, r:Record, ri:int}:#Background
{return
{if r["selected"] asa bool then
"#ffff0080"
else
null
}
}
},
automatic-columns? = false,
{RecordGridColumn width = 18pt, "selected",
header-spec = select-all-ctrl,
halign = "center"
},
{RecordGridColumn width = 3.5in, "Title"},
{RecordGridColumn width = 60pt, "Date"}
}
}
{do
{rg.records.add-event-handler
{on RecordModified at rv:RecordView do
let all?:bool = true
{for r:Record key ri:int in rg.records do
{if not rg.records[ri]["selected"] asa bool then
set all? = false
{break}
}
}
set select-all-ctrl.value = all?
}
}
}
{value rg}