Is there any plan to modify TDataSource.Enabled property? lazarus / 16-Databases ---------------------------------------------------------------------- egsuh · 2021-07-19 08:32 If TDataSource.Enabled is set to false, then all the Data-aware controls linked to it should not show any content. Currently it does not seem to operate. Is there any plan to implement this? ---------------------------------------------------------------------- GAN · 2021-07-19 20:42 I don't think so, to achieve that, you use the active property of the Tdataset that is linked to the TDataSource. ---------------------------------------------------------------------- JuhaManninen · 2021-07-20 07:28 Sounds like a bug though. Does it work in Delphi? A patch to implement it would be accepted surely. ---------------------------------------------------------------------- wp · 2021-07-20 08:28 Justs checked with Delphi 7, XE2 and XE 10.3.3 (Community Edition): They behave as described in the first post - a dbgrid attached to a TDataSource becomes empty when DataSource.Enabled is switched to false, and this corresponds to Embarcadero documentation (http://docwi ki.embarcadero.com/Libraries/Sydney/en/Data.DB.TDataSource.Enabled). The dataset, however, is not "closed" as I can see when I query the state of Dataset.Active periodically when the application is idle. I wonder what this strange property could be good for... The Embarcadero help says also: "While an application can set Enabled to false to blank out data-aware controls during processing of multiple records, a better choice is to use the TDataSet EnableControls and DisableControls methods. Using these methods prevents the controls from blanking out during processing." This sounds as if this property is a poorly-thought left-over from the beginnings. ---------------------------------------------------------------------- Zoran · 2021-07-20 08:48 I think that quite same behaviour can be achieved by setting DataSoruce.DataSet to nil. The dataset will not be closed, but the content of the connected db controls will disappear. Then, if you want to "enable" the datasource again, you can set DataSource.DataSet back to the dataset. ---------------------------------------------------------------------- egsuh · 2021-07-20 11:03 I can achieve the same effect by setting datasource.dataset to nil, and to dataset. But this just looks little bit clumsy -- nothing else. DataSet.Enable/disableControls --> In some cases, I might want to connect two datasources to one dataset, and keep one on and another one off. Anyway there is a property but it does not operate as expected and documented. https://www.freepascal.org/docs- html/current/fcl/db/tdatasource.enabled.html  says, QuoteEnabled is by default set to True: the datasource instance communicates events from the dataset to components connected to the datasource, and vice versa: components can interact with the dataset. If the Enabled property is set to False then no events are communicated to connected components: it is as if the dataset property was set to Nil. Reversely, the components cannot interact with the dataset if the Enabled property is set to False. BTW, TBufDataSet.Close seems to remove the database altogether. Can't I close it and then open again? ---------------------------------------------------------------------- wp · 2021-07-20 11:29 Quote from: Zoran on July 20, 2021, 10:48:24 amI think that quite same behaviour can be achieved by setting DataSoruce.DataSet to nil. The dataset will not be closed, but the content of the connected db controls will disappear. But this would break code imported from Delphi where Datasource.Dataset is <> nil in this case. ---------------------------------------------------------------------- LacaK · 2021-07-20 12:42 Yes it seems, that Enabled property is not used. I think that it can be implemented (something like in attached patch). Can somebody fill bug report ...? Or if somebody can confirm, that attached patch fixes problem then I can commit it ... ---------------------------------------------------------------------- devEric69 · 2021-07-20 15:17 For info., I've just tested @LacaK's patch on a single table (without master record and its details records pattern): assigning "datasource.Enabled:= false" de-illuminates its navigator (all its buttons become grey) as we should expect (tested with its IBX grid too, wich is not disabled, or emptied of data, as if the transactional connection was disabled, desactived; but this is not really abnormal with such transactionnal clients-server + cached updates layers). ---------------------------------------------------------------------- LacaK · 2021-07-22 08:13 Patch was applied in rev.49630 ---------------------------------------------------------------------- devEric69 · 2021-07-22 09:14 Thanks you very much @LacaK (the logic of your correction in the source code is simple and clear, for me anyway).