GUI Questions (FireDAC)

From RAD Studio
Jump to: navigation, search

Go Up to FAQ (FireDAC)

This topic contains a list of questions and answers related to the FireDAC GUI.

Q1: How can I show the "Application is busy" dialog while a long running query is executing?

A: Set FDQuery.ResourceOptions.CmdExecMode to amCancelDialog, drop TFDGUIxAsyncExecuteDialog to a form, then prepare a test with a long running query and run it.

While the query is executing, FireDAC will show a dialog with the "Wait" label and the "Cancel" button. If the user presses the button, the query execution is canceled.

Q2: How can I localize the FDGUIxLoginDialog?

A: Use code like the below:

with FDGUIxLoginDialog1.VisibleItems do begin
  Clear;
  Add('User_Name=<local phrase>');
  Add('Password=<local phrase>');
end;

Also, you can open FireDAC.Stan.ResStrs unit, find a section "Dialog captions" and translate the items.

Q3: How can I handle the errors using TFDGUIxErrorDialog?

A: Just drop the TFDGUIxErrorDialog component on your form or data module. Then for the EFDDBEngineException unhandled exceptions, the FireDAC error dialog will be shown. To achieve that, FireDAC hooks the TApplication.OnException event.

Q4: How can I turn off the SQL hourglass completely?

A: a) To disable the wait cursor completely for an application, use TFDGUIxWaitCursor with Provider = 'Console'. The 'Console' provider contains an empty wait cursor implementation and the wait cursor will no longer be shown by FireDAC. If a mouse cursor is still changing, then check that only FireDAC.ConsoleUI.Wait unit is included into your application and FireDAC.VCLUI.Wait and FireDAC.FMXUI.Wait are not included. Note that you will not have the ability to turn the wait cursor on again.

b) To disable the wait cursor, but to have the ability to enable it again later, use code like the following:

FDWaitCursor1.ScreenCursor := gcrNone;

or

FDManager.ResourceOptions.SilentMode := True;

c) To disable the wait cursor and FireDAC dialogs, but to have the ability to enable them again later, set the FDManager.SilentMode property to True. This will disable all wait cursors and FireDAC dialogs, including:

  • The error dialog
  • Async execution dialog
  • Login dialog
  • Script progress dialog

Setting ResourceOptions.SilentMode to True disables only wait cursors.

Q5: When I apply a filter to a dataset, the grid scroll bar remains unchanged. Why is that?

Q: I have a grid connected to FDDataSet. When I filter records like this:

Grid.DataSource.Dataset.Filter := 'id_virtual_channel in (1, 2, 3)'

everything is OK, but the scroll bar remains unchanged, as if all the rows were shown. It looks quite bad when, for example, a full grid has 500 rows and filtered only 3, but the scroll bar cursor stays very small and you can move it only very little (like from the first to the third row in 500). Do you have a solution?

A: Use code like the following:

FDQuery1.FetchOptions.RecordCountMode := cmVisible;

Q6: After refreshing a dataset, a DBGrid with multiple selected rows loses the selection. How can I preserve the selection?

A: FireDAC bookmarks are invalidated after a Refresh call. You can save PK values of the selected records before the Refresh call, then reselect these record again using Locate.