0

I am using the cxGrid. I have a field (column) in my grid that is of boolean type (true/false) represented in the grid as a checkbox. How can I make all the checkboxes in the column checked (or unchecked) on button click ?

it looks like this :

enter image description here

Now I would like, on button click, to turn those 3 checkboxes checked BEFORE I save everything.. DATA on the left(USERS) comes from a table, the data on the right is from a query. The SAVE of everything goes to a separate LOG table.

When I hit 'Check all' button,the result :

enter image description here

I could run the update query : update MYFIELD set SELECTED = '2'; but I am more interested in manipulating the grid itself.Something simple...

user763539
  • 3,509
  • 6
  • 44
  • 103

2 Answers2

1

You will have to add a button or pop up menu somewhere on your form to accept the check all 'command', or maybe even place a checkbox in your column header. Then go through your underlying dataset and set all field values. Don't forget a DisableControls/EnableControls.

Jan Doggen
  • 8,799
  • 13
  • 70
  • 144
  • I do not want to manipulate the underlying database data. I want the grid to check/uncheck all. I know this can be done. – user763539 Dec 09 '13 at 16:13
  • Do you mean to say that that column is not bound to an underlying database field? Or is it a calculated field maybe? Or does your TcxGrid not have the default TcxGridTableView? Please update your question with enough info. – Jan Doggen Dec 09 '13 at 16:17
  • The data, when first displayed, is for input purposes where user only checks or unchecks a checkbox. Nothing else. When he finishes ,he saves the whole thing to a database. If I remember correctly, cxgrid has the ability to set cell values using a script. – user763539 Dec 09 '13 at 16:26
  • @user763539: http://stackoverflow.com/questions/14385714/devexpress-grid-with-unbound-column? – MartynA Dec 09 '13 at 16:27
  • That is in itself an interesting post, but the author of the answer confesses it's ugly. Maybe your better off adding an fkInternalCalc field to your dataset, so that you can have a bound checkbox that you don't need to write back to the DB. – Jan Doggen Dec 09 '13 at 16:29
0

added an extra field to my table (boolean type) and changed its property in the cxGrid to that of a checkbox.Then on button click:

with uniquery1 do begin
  Active:=False;
  sql.Clear;
  SQL.Add('update users set selected = 0'); //or '1'
  execSql;
end;
Uniquery1.Refresh;

this I found was the easiest way ....

user763539
  • 3,509
  • 6
  • 44
  • 103