when to use fncgrid.beginupdate

Not sure if the following code should have fncgrid.beginupdate and fncgrid.endupdate?

if FDTBL1.FieldByName('FOBPOINT').AsString = 'None' then
BEGIN
SALESGrid.BeginUpdate;
SALESGrid.Comments[23,SALESGrid.FocusedCell.Row] := '';
SALESGrid.EndUpdate;
END;
SalesitemsGrid.BeginUpdate;
SalesitemsGrid.Options.Editing.Enabled := True;
SalesitemsGrid.EndUpdate;

What about datagrid.beginupdate?

SalesitemsdataGrid.BeginUpdate;
SalesitemsdataGrid.Options.Editing.Enabled := True;
SalesitemsdataGrid.EndUpdate;

Thanks

Garnett

Is this code from initialization? or in some event? If it’s initialization, it cannot hurt adding BeginUpdate/EndUpdate.

SALESListGridCellClick(Sender: TObject; ACol, ARow: Integer);

cellclick to load fncgrid

So, When and how should FNCGRID.beginupdate be used?

SALESListDATAGridCellClick(Sender: TObject; ACol, ARow: Integer);

cellclick to load the master datagrid

So, When and how should FNCdataGRID.beginupdate be used?

Thanks

Garnett

The rule is that everything in the grid can be done without beginupdate/endupdate, but if you need to load lots of data and this takes time use beginupdate/endupdate to speed up the process. Always use them outside of any grid event that manipulates cells such as OnGetCellLayout. Click events should be safe

What event to use to have the subdatagrid to expand instead of the mouse click?

Thanks

Garnett

please disregard the this request!

Thanks learning

Garnett

No worries, can you share the approach you used?

procedure TBOMForm.MOBOMDATAGridAfterCloseInplaceEditor(Sender: TObject;
ACell: TTMSFNCDataGridCellCoord; ACancel: Boolean;
AValue: TTMSFNCDataGridCellValue);
VAR
TCOST : DOUBLE;
LG : INTEGER;
begin
TCOST := 0;
if not ACancel then
begin
if MOBOMDATAGridDatabaseAdapter.DataLink.DataSet.State in [dsEdit] then
begin
MOBOMDATAGridDatabaseAdapter.DataLink.DataSet.Post;
LABEL9.Text := 'Status: Updated : '+AVALUE.ToString;
end;
if (acELL.Column = 7) and (aCELL.row = MOBOMDATAGrid.FocusedCell.Row) then
BEGIN
if (FDTbl9BA.FieldByName('STATUS').AsString = 'Entered') then
BEGIN
FDTBL9D.First;
while NOT FDTBL9D.EOF do
BEGIN
FDTBL9D.EDIT;
FDTBL9D.FieldByName('QTYTARGET').AsFLOAT := (FDTBL9D.FieldByName('QTY').AsFLOAT * FDTbl9BA.FieldByName('QTY').ASINTEGER);
FDTBL9D.FieldByName('TOTALCOST').AsFLOAT := roundto(FDTBL9D.FieldByName('COST').AsFLOAT * FDTbl9BA.FieldByName('QTY').ASINTEGER,-2);
tcost := tcost + FDTBL9D.FieldByName('TOTALCOST').AsCurrency;
try
FDTBL9D.Post;
EXCEPT
on E: Exception do
showmessage('Exception Raised MO ITEM Post with message : '+ #13#10 + E.message);
END;
FDTBL9D.Next;
END;
FDTBL9BA.EDIT;
if FDTbl9BA.FieldByName('QTY').ASINTEGER = 1 then
FDTBL9BA.FIELDBYNAME('COST').AsCurrency := tcost
ELSE
FDTBL9BA.FIELDBYNAME('COST').AsCurrency := ROUNDTO(tcost/FDTbl9BA.FieldByName('QTY').ASINTEGER,-4);
FDTBL9BA.FIELDBYNAME('TOTALCOST').AsCurrency := ROUNDTO(tcost,-2);
if MOBOMDATAGridDatabaseAdapter.DataLink.DataSet.State in [dsEdit] then
begin
MOBOMDATAGridDatabaseAdapter.DataLink.DataSet.Post;
LABEL9.Text := 'Status: Updated : '+AVALUE.ToString;
end;
END;
MOBOMDATAGrid.BeginUpdate;
MOBOMDATAGrid.ExpandNode(ACell.Row);
MOBOMDATAGrid.EndUpdate;
WOitemsDataGrid.UpdateCalculations;
end;
end;
end;

The above code is how I am handling it. If you see something please comment.

Thanks
Garnett