Domanda

I am using these components:

UniDac for connection to mysql database
DevExpress for QuantumGrid

IDE:

Embarcadero Rad Studio XE2

I have a cxGrid component with one level and a cxGrid1DBTableView specified as the level's View. I can get data from my database and edit it in the grid. I want to add a column that is not in the bound DataSet. When I specify the Column properties value as CheckBox I can see the column but I can't change the value from unchecked to checked by clicking it. The field doesn't have a DataBinding assigned to it. I tried other types of Properties but all are the same I cant change the row value in the grid.

I've been searching for a way to fix this for couple of days, so im hoping you guys can help me.

È stato utile?

Soluzione

Are you trying to add a checkbox item that does not have a database field behind it? I have this on one of my forms.

In addition to setting the Properties to "Checkbox" you need to set the DataBinding -> ValueType to "Boolean". The DataBinding->FieldName can be left blank.

To access the values or change their defaults you can use the DataController like this:

View.DataController.Values[i, CheckBoxFieldIndex] := true;

In addition you need to set

DataController.DataModeController.SmartRefresh := true; 

To set that option you will also need a KeyField defined for the Controller (DataController.KeyFieldNames)

Setting the SmartRefresh to true will prevent the grid from trying to get an updated value from the underlying dataset. You need to prevent the refresh or the value for the non-bound column will be set back to Null. This comes with some restriction on how you update your dataset. Any changes made to the data in code will not be reflected by the grid unless you explicitly refresh the grid.

Altri suggerimenti

You also have to fill the field View.DataController.KeyFieldNames with one of the datasets fields. At least I need it in Delphi 7.

Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow
scroll top