I have a cxGrid where I apply a filter to select certain records. When that is done I want to be able to update a field/column in the grid to mark each record that is to be used for the next operation. I haven't been able to figure this out
Maybe I haven't been specific enough when describing my problem. I have the cxGrid where I have applied a filter selecting some records. What I then need to do is to click a columnheader and then have a field called fldselected set to True for these records.
Check out https://www.devexpress.com/Support/Center/Question/Details/A1095, the article from Dev Express. Don't let the fact that the article is 11 years old fool you. The same technique still applies. And you can set this up either in code or in the grid editor.
An unbound column can be referenced in your next operation using the DataController Records or Values array, depending on how you set that up. Because it is unbound you cannot reference it through the underlying DataSet though.
What your updated q is asking for is straightforward and as usual with Devex stuff, it's all in the OLH as long as you can find your way into it.
A way to find which rows currently match the filter is to use the
property. You can then find that record in the dataset to process it in some way using
Update: The original version of this answer assumed that the dataset had an integer ID field. As the OP has said he uses GUIDs instead, I've upddated it accordingly.
Assuming the TClientDataSet CDS1 has fields Guid : TGuidField, Name : TStringfield, size 32 and Selected : TBooleanField and is connected to a cxDBTableView, with filtering enabled, of a TcxGrid.
Make sure the cxGrid1DBTableView1.DataController.KeyFieldNames is set to 'Guid'.
Add a regular TDBGrid to the form and point it at the same datasource as the TcxGrid. The point of this is to make it easy to verify that the code is working as required.
Add the code below to the unit, and point cxDBTableView1's OnColumnHeaderClick at the handler cxGrid1DBTableView1ColumnHeaderClick, and the form's OnCreate at the FormCreate.
Compiler & run
Code: