We have used cxGrid1ServerModeTableView
(VCL) in our project .but our biggest problem is that we cannot synchronize
cxGrid with DB controls. We don’t want to use Inplace Editor.for editing
records we should use DB controls of Delphi.
What is the best way of
binding and synchronizing cxGrid with DB controls?
When will you support
this capability in cxGrid1ServerModeTableView ?
We have closed this ticket because another page addresses its subject:
Server Mode - Improve data interoperability between server mode data sources and standalone data-aware editors bound to the same databaseserver mode & db control synchronization
Answers approved by DevExpress Support
Hello,
Thank you for your question. We have no plans to implement such synchronization at the level of our controls as we already have the in-place editing capability. You can use the following approach to implement the synchronization yourself:
- Link your DB editors to a table used to display data in the Server Mode View;
- Handle the <ServerModeView>.OnFocusedRecordChanged event and locate the current record by the key value:
Delphiprocedure TForm1.cxGrid1ServerModeTableView1FocusedRecordChanged(
Sender: TcxCustomGridTableView; APrevFocusedRecord,
AFocusedRecord: TcxCustomGridRecord;
ANewItemRecordFocusingChanged: Boolean);
var
ID: Variant;
begin
ID := Sender.DataController.GetValue(AFocusedRecord.RecordIndex, 0);
if ADOTable1.Active then
ADOTable1.Locate(dxServerModeADODataSource1.KeyFieldNames, ID, []);
end;
- Handle the DataSet's OnAfterPost event, and update the Server Mode View's DataController and DataSource data there:
Delphitype
TdxServerModeADODataSourceAccess = class(TdxServerModeADODataSource);
procedure TForm1.ADOTable1AfterPost(DataSet: TDataSet);
begin
TdxServerModeADODataSourceAccess(dxServerModeADODataSource1).Cache.SoftReset;
cxGrid1ServerModeTableView1.DataController.Refresh;
end;
P.S.: We plan to slightly simplify this algorithm with future versions of our controls (see the Server Mode - Improve data interoperability between server mode data sources and standalone data-aware editors bound to the same database ticket).
- This Is not good Solution for me because it needs one time cxGrid in server Mode send request to server & Other Time my Dataset send request to server Then two time send request required
- i Patched devexpress grid :: DoExecuteCommand & FetchRows to use internal devX grid dataset
why Do not grant user to use internal cxGrid Dataset ?
or better way : use Sql Dataset as Base for Dataset ?
function TdxServerModeADQueryDataSource.FetchRows(AWhere: TdxServerModeCriteria; ASortInfo: TdxServerModeSortInfoDescriptors; ATopRecords: Integer): TdxServerModeRowList;
begin
Result := TdxServerModeRowList.Create;
if ExecuteCommand(@FADataSet, FieldDescriptors, AWhere, ASortInfo, nil, ATopRecords, 0) then
try
while not FADataSet.Eof do
begin
Result.Add(dxCreateServerModeRow(FADataSet.Fields));
FADataSet.Next;
end;
finally
//ADataSet.Free;
//ADataSet.First;
end;
end;
procedure TdxServerModeDataSourceADHelper.DoExecuteCommand(AResultSet: PDataSet; const ACommand: string; AParams: TParams;
AParamCheck: Boolean);
var
I: Integer;
begin
Query:=nil; //changed
query:=TADQuery.Create(nil);
try
query.Close;
query.Connection := TADConnection(Connection);
if (AParams <> nil) and (AParams.Count > 0) then
begin
query.SQL.Text := ACommand;
for I := 0 to AParams.Count - 1 do
query.Params[I].Value := AParams[I].Value;
query.Open();
AResultSet^ :=query;
end
else
begin
query.Open(ACommand);
AResultSet^ :=query;
end;
// Query.Close; don't close
finally
// FreeAndNil(Query); don't free
end;
end;
This Patch have any problem ?
Hello,
I doubt that this code can help you implement a reliable solution for your task. In Server Mode our grid gets data from the server portion by portion. So the FADataSet DataSet will contain only the latest requested portion. Moreover, it is not always correct to use the TDataSet.Open method you are using in DoExecuteCommand. It is necessary to use the TDataSet.ExecSQL method instead in certain cases (e.g., when deleting a record).
I suggest you use features we implemented in the context of the Server Mode - Improve data interoperability between server mode data sources and standalone data-aware editors bound to the same database ticket to synchronize DB editors with Server Mode.