d.bernaert Posted November 8, 2018 Share Posted November 8, 2018 Hi, I would like to store the visible columns in each grid and the width of each visible column so when the user enters the same form again he gets the same view again. It is my purpose to store this to a database so the user gets the same lay-out on any machine he uses. Thx, Bernaert Dominique Link to comment Share on other sites More sharing options...
Tokay Posted November 8, 2018 Share Posted November 8, 2018 I have wrote such a class. But it has the dependence of the JVCL library. I don't know, is it good idea to piblish it. It can save and restore Width, Index, Visible and Expanded properties of each column in a TUniDBGrid. On the server side, store by user, in registry, db, xml or ini file. Link to comment Share on other sites More sharing options...
d.bernaert Posted November 8, 2018 Author Share Posted November 8, 2018 Hi, would it be possible to send it over? I would like to take a look at it if you would be willing to share this? If you don't want to post it public, please send me a private message. Would be greatly appreciated. Thx, Dominique Link to comment Share on other sites More sharing options...
Tokay Posted November 9, 2018 Share Posted November 9, 2018 Okay, here's this module. Usage, forms, pas: procedure TUniForm14.UniFormClose(Sender: TObject; var Action: TCloseAction); begin JvFormStorage1.StoredValues.Values['Form14Width'].Value := Width; JvFormStorage1.StoredValues.Values['Form14Height'].Value := Height; SaveGridLayout; JvFormStorage1.SaveFormPlacement; end; procedure TUniForm14.UniFormCreate(Sender: TObject); begin JvFormStorage1.AppStorage := UniMainModule.AppRegistryStorage; JvFormStorage1.RestoreFormPlacement; Width := JvFormStorage1.StoredValues.Values['Form14Width'].Value; Height := JvFormStorage1.StoredValues.Values['Form14Height'].Value; LoadGridLayout; end; procedure TUniForm14.SaveGridLayout; var SaveLayout: TUniGridLayOut; begin SaveLayout := TUniGridLayOut.Create(nil); try SaveLayout.SaveLayout(JvFormStorage1, UniDBGrid1, 'Form14Grid1'); SaveLayout.SaveLayout(JvFormStorage1, UniDBGrid2, 'Form14Grid2'); finally FreeAndNil(SaveLayout); end; end; procedure TUniForm14.LoadGridLayout; var LoadLayout: TUniGridLayOut; begin LoadLayout := TUniGridLayOut.Create(nil); try LoadLayout.LoadLayout(JvFormStorage1, UniDBGrid1, 'Form14Grid1'); LoadLayout.LoadLayout(JvFormStorage1, UniDBGrid2, 'Form14Grid2'); finally FreeAndNil(LoadLayout); end; end; DFM: object JvFormStorage1: TJvFormStorage Active = False AppStoragePath = 'Form14Placement\' Options = [] StoredValues = < item Name = 'Form14Width' Value = 943 end item Name = 'Form14Height' Value = 688 end> Left = 559 Top = 164 end Usage, the MainModule, pas: procedure TUniMainModule.UniGUIMainModuleBeforeLogin(Sender: TObject; var Handled: boolean); begin if Handled then begin ..... AppRegistryStorage.Root := AppRegistryStorage.Root + '\' + UniMainModule.LoggedUserUID; end; end; DFM: object AppRegistryStorage: TJvAppRegistryStorage StorageOptions.BooleanStringTrueValues = 'TRUE, YES, Y' StorageOptions.BooleanStringFalseValues = 'FALSE, NO, N' Root = 'Software\ACME Software\UniGuiStorage' SubStorages = <> Left = 504 Top = 216 end SaveUniGrid.pas Link to comment Share on other sites More sharing options...
Recommended Posts
Please sign in to comment
You will be able to leave a comment after signing in
Sign In Now