Subject | Re: [IBO] Editable calculated field |
---|---|
Author | Lucas Franzen |
Post date | 2004-10-06T18:30:05Z |
Hi Daniel,
Daniel Albuschat schrieb:
Since it looks, you don't like to use a button that does the trick, you
could use the OnCellDblClick (or OnCellClick event of the IB_Grid:
// names:
aQry = Underlying IB_Query
MyGrid = IB_GRid
CalculatedField name is 'CALCFIELD'
aDSql: TIB_DSQL that does and update to the field which causes the
Calculated field(s) to be TRUE pr FALSE
procedure TForm.MyGridCellDblClick(Sender: TObject; ACol,
ARow: Integer; AButton: TMouseButton; AShift: TShiftState);
var
tmpFld: TIB_Column;
begin
if ( aQry.Active ) AND
( NOT aQry.isEmpty ) AND
( aRow > 0 ) AND
( ACol > 0 ) then
begin
tmpFld := myGrid.GridFields[ myGrid.DataCol[ ACol ]];
if Assigned( tmpFld ) AND
( tmpFld.FieldName = 'CALCFIELD' ) then
begin
with aDSql do
begin
try
// do your update according to the value of your CALFIELD
// you can access this value just normal by
// aQry.FieldByName ( 'CALCFIELD' ).AsString ...
// Update succesful
aQry.InvalidateRowNum ( myGrid.DataRow[aQry.RowNum] );
except
end
end;
end;
end;
end;
This way you can keep the Query itself ReadOnly (if you don't edit other
field in the Grid directly...)
If you want to have RequestLive set tot TRUE for the IB_Query then you
don't need an extra DSQL...
(it's just that I don't like editing data in a IB_Grid in a multi-user
environemnt...)
Luc.
Daniel Albuschat schrieb:
> Hello,workaround:
>
> I want to create a TCheckBox-like
> list with a TIB_Grid. The very first column
> should be a Checkbox which can be selected
> and de-selected. I thought the easiest way would
> be a calculated field of type char, and then
> add the ColumnAttributes accordingly:
> Select "Boolean", set True Text / False Text to
> T/F respectively and select the "Required" option.
> But there's the problem that I can't change this
> field, since calculated fields are always read-only...
>
> Any suggestions to get the calculated fields approach
> to work, or another solution?
Since it looks, you don't like to use a button that does the trick, you
could use the OnCellDblClick (or OnCellClick event of the IB_Grid:
// names:
aQry = Underlying IB_Query
MyGrid = IB_GRid
CalculatedField name is 'CALCFIELD'
aDSql: TIB_DSQL that does and update to the field which causes the
Calculated field(s) to be TRUE pr FALSE
procedure TForm.MyGridCellDblClick(Sender: TObject; ACol,
ARow: Integer; AButton: TMouseButton; AShift: TShiftState);
var
tmpFld: TIB_Column;
begin
if ( aQry.Active ) AND
( NOT aQry.isEmpty ) AND
( aRow > 0 ) AND
( ACol > 0 ) then
begin
tmpFld := myGrid.GridFields[ myGrid.DataCol[ ACol ]];
if Assigned( tmpFld ) AND
( tmpFld.FieldName = 'CALCFIELD' ) then
begin
with aDSql do
begin
try
// do your update according to the value of your CALFIELD
// you can access this value just normal by
// aQry.FieldByName ( 'CALCFIELD' ).AsString ...
// Update succesful
aQry.InvalidateRowNum ( myGrid.DataRow[aQry.RowNum] );
except
end
end;
end;
end;
end;
This way you can keep the Query itself ReadOnly (if you don't edit other
field in the Grid directly...)
If you want to have RequestLive set tot TRUE for the IB_Query then you
don't need an extra DSQL...
(it's just that I don't like editing data in a IB_Grid in a multi-user
environemnt...)
Luc.