Jump to content

WalkingAway

Members
  • Content Count

    27
  • Joined

  • Last visited

Everything posted by WalkingAway

  1. WalkingAway

    RefreshUnknownRecord, FDQuery

    Hi. I use the RefreshUnknownRecord function to manually add rows (bypassing Fetch) together with "normal" Fetch (with fmOnDemand and RecsMax, RowSize etc.). I have side effect, I will try to describe it: 1) Fetched first 100 tuples (let say Id is from 1 to 100) 2) With RefreshUnknownRecord added row with id = 101 3) Fetched second 100 tuples (id from 101 to 200). In this situation I have row 101 duplicated. Is there any way to awoid this? I think to implement some kind of array of variant for keeping records added with RefreshUnknownRecord and checking in OnFecth event and skeep them (as already present). Thank you.
  2. I have such a test classes (copy of TFDAdaptedDataSet, TFDCustomMemTable and TFDMemTable): unit xDataSet; interface uses System.SysUtils, System.Classes, Data.DB, FireDAC.Comp.DataSet, Firedac.Stan.Def, Firedac.Stan.Param, Firedac.Stan.Option, Firedac.DatS, Firedac.Phys.Intf; type TxBaseDataSet = class(TFDDataSet) private { Private declarations } protected { Protected declarations } public { Public declarations } constructor Create(AOwner: TComponent); override; destructor Destroy; override; { TFDDataSet } property FetchOptions; property FormatOptions; property ResourceOptions; property SecurityOptions; property UpdateOptions; published { Published declarations } end; TxCustomDataSet = class(TxBaseDataSet) private FOptionsIntf: IFDStanOptions; protected FStoreDefs: Boolean; property StoreDefs: Boolean read FStoreDefs write FStoreDefs default False; // IFDStanOptions function GetOptionsIntf: IFDStanOptions; override; procedure GetParentOptions(var AOpts: IFDStanOptions); public constructor Create(AOwner: TComponent); override; destructor Destroy; override; end; TxDataSet = class(TxCustomDataSet) published property ActiveStoredUsage; { TDataSet } property Active; property AutoCalcFields; property BeforeOpen; property AfterOpen; property BeforeClose; property AfterClose; property BeforeInsert; property AfterInsert; property BeforeEdit; property AfterEdit; property BeforePost; property AfterPost; property BeforeCancel; property AfterCancel; property BeforeDelete; property AfterDelete; property BeforeScroll; property AfterScroll; property BeforeRefresh; property AfterRefresh; property OnCalcFields; property OnDeleteError; property OnEditError; property OnNewRecord; property OnPostError; property FieldOptions; property Filtered; property FilterOptions; property Filter; property OnFilterRecord; property ObjectView default True; property Constraints; property DataSetField; property FieldDefs stored FStoreDefs; { TFDDataSet } property CachedUpdates; property FilterChanges; property IndexDefs stored FStoreDefs; property Indexes; property IndexesActive; property IndexName; property IndexFieldNames; property Aggregates; property AggregatesActive; property ConstraintsEnabled; property MasterSource; property MasterFields; property DetailFields; property OnUpdateRecord; property OnUpdateError; property OnReconcileError; property BeforeApplyUpdates; property AfterApplyUpdates; property BeforeGetRecords; property AfterGetRecords; property AfterGetRecord; property BeforeRowRequest; property AfterRowRequest; property BeforeExecute; property AfterExecute; property FetchOptions; property FormatOptions; property ResourceOptions; property SecurityOptions; property UpdateOptions; { TxCustomCustomDataset } property StoreDefs; public constructor Create(AOwner: TComponent); override; destructor Destroy; override; end; procedure Register; implementation procedure Register; begin RegisterComponents('Samples', [TxDataSet]); end; { TxBaseDataSet } constructor TxBaseDataSet.Create(AOwner: TComponent); begin inherited Create(AOwner); end; destructor TxBaseDataSet.Destroy; begin inherited Destroy; end; { TxustomCustomDataset } constructor TxCustomDataSet.Create(AOwner: TComponent); begin inherited Create(AOwner); end; destructor TxCustomDataSet.Destroy; begin Close; Destroying; inherited Destroy; if FOptionsIntf <> nil then begin FOptionsIntf.ObjectDestroyed(Self); FOptionsIntf := nil; end; end; function TxCustomDataSet.GetOptionsIntf: IFDStanOptions; begin if FOptionsIntf = nil then FOptionsIntf := TFDOptionsContainer.Create(Self, TFDFetchOptions, TFDBottomUpdateOptions, TFDBottomResourceOptions, GetParentOptions); Result := FOptionsIntf; end; procedure TxCustomDataSet.GetParentOptions(var AOpts: IFDStanOptions); begin AOpts := nil; end; { TxDataSet } constructor TxDataSet.Create(AOwner: TComponent); begin inherited Create(AOwner); end; destructor TxDataSet.Destroy; begin inherited Destroy; end; end. Nothing wrong here. But I can not add quite simple thing - I want to override FetchOptions.Mode (let say, it alway has to be fmAll - no metter what was set in design time). What I see - value from design time is always som how written in the end. So, when I put FetchOptions.Mode = fmAll to all three available Create methods - constractors, nothing changes. How to do it? Also, if I put component to form and ask its mode, it is always what was set in design time. procedure TForm22.Button1Click(Sender: TObject); begin case xDataSet1.FetchOptions.Mode of fmAll: begin ShowMessage('fmAll'); end; fmExactRecsMax: begin ShowMessage('fmExactRecsMax'); end; fmManual: begin ShowMessage('fmManual'); end; fmOnDemand: begin ShowMessage('fmOnDemand'); end; end; end; Thank you.
  3. I want to have list of documents in one form (simple query) and edit form for particular document in other form (extended query). In simplier case - when the same query is used - I have no problems at all, everything is clear. Goal is to have simple / light query for list (let say, common fields - id, name) and more extended version for edit form (almost every field included) potentially with master / detail and CachedUpdates. Editing case itself I can imaging (how to implement), but what about adding? Especially if user cancel adding. I mean how to link both queries as it was the same (actually both queries for the same document) - if editor is closed (and product was created), how to update list (not update, but refresh one row). Thank you in advance!
  4. Hi there! As it turns out, my question is intertwined with this article from @Uwe Raabe https://www.uweraabe.de/Blog/2020/10/04/tweaking-dfm-loading/ The example in this article does not take into account adding (editing only), and here is implemented absolutely what I'm looking for - in the main form / edit form is used different datasources. So, if save the record, I just need only to call Refresh method for retrieving new / updated values for only one record. At least it should work. But still not understand, how to do it in case of adding new record (employee in that case) - if I put dsData.DataSet.Insert (for editing dsData.DataSet.Edit do the job), I can't call Refresh (or it has no sence probabaly), I even can't temporaraily Post (user probably can press "Cancel" later - no adding at all) Thanks. TweakingDFMLoading.zip
  5. Just for education purpose decided to test Midware (with Rio additions). In general, it works, but: 1) can get it working with SSL - there is no TSslAppSrvClient component. Do I have use "normal" TAppSrvClient instead? 2) lzh not working - MidWare implementation has f.e. EncryptGetBytes method and second param is LongWord (but in lzh.pas wich was found in internet it has type Word). 3) Is this library support unicode? Can somebody explain me what can I do in order to get it working?
  6. WalkingAway

    [MidWare] MidWare, Delphi 12

    François, thank you for your work. It so nice that it is open project and possible to get know how it works. I have builded all the samles and their are working. My questions were based just in found cooments - those SSL and ZHL features. Probably in some point it was implemented (or was some tryout to implement). Also was found some comment about unicode, it was also asked. Thank you.
  7. WalkingAway

    [MidWare] MidWare, Delphi 12

    Thank you so much. It is very useful to know in advance what feature is impossible to find. But itself your framework / libaray is quite good base for simple / educational projects. Thanks.
  8. WalkingAway

    Spring4D + DSharp = RAD Alexandria

    Maybe Stefan can give some hint how to proceed. In some old project (RAD Berlin) I have used Spring4D + DSharp - - both 1.2.1 (and then DDuce's ListDataSource for showing data in GUI). Working well. In modern RAD Alexandria I'm using Spring4D (generally for lists and dep.inj.). But I'm not able to compile DSharp anymore. Only Spring4D 1.2.1 + DSharp 1.2.1 give that pair to compile. But anyway it is not possible to install DSharp designtime packages for binding (it is my goal - to use DSarp as binding library), Delphi throw always "Invalid pointer operation" as long as DSharp.Bindings used in use clause. Can't fix it. Seems like DSarp discontinued or depricated. I can't find version for Alexandria. Actually, ListDataSource from DDuce was removed as depricated, and I have not noticed that in Spring there is similar feature - Spring.Persistence.ObjectDataSet or something similar. So I can probably do the same in pure Spring4d library - bind my own list of class (let say TList<TMySettings>) to bidirectionally binding to grid as ordinary dataset. Thanks in advance.
  9. WalkingAway

    Bindings problem

    Hello I have problem. FMX and Android, TListView with binded DataSet. Phone is EN, but Text := 'äÄåÅ' (SCANDINAVIAN); Items when binded - not displayed properly, but this working correctly: procedure TForm5.ListView1ItemClick(const Sender: TObject; const AItem: TListViewItem); begin AItem.Text := 'äÄåÅ'; end; How to solve this problem? Thank you
  10. WalkingAway

    Bindings problem

    Solution found Just changed dasetfield from string ti wide string
  11. WalkingAway

    RTTI and not ordinary data type

    Is it possible to get / set through RTTI non standard type value? I tries, but always got something like 'invalid tapecast' error. Let say I have TFrameMeta<T: TFrame> = class(TGlobalMeta) TGlobalMeta here is: TGlobalMeta = class private What I want - to unified opportunity to set / get "Meta" value , it can be FirstFrame.Meta, SecondFrame.Meta, ... Now I have to write if FirstFrame.Meta is AccountFrame then ... else if FirstFrame.Meta is ReportFrame If I have 50 frames it is too boring. RTTI may help me Or maybe mnthere some libraries for that Thank a lot Also I want to link that kind of link to "Meta" to listview (TValue.From) for same purpose. With no success also so far...
  12. WalkingAway

    RTTI and not ordinary data type

    I have here such a sample app. This app using StandFrame component, but it can be plain / pure frame based app. Main question here is: Every frame has "meta" - information about itself (managed by FrameStand), and code is basically the same: procedure TMainForm.PictureButtonClick(Sender: TObject); var LFrameInfo: TFrameInfo<TPictureFrame>; begin LFrameInfo := FrameStand1.New<TPictureFrame>(); LFrameInfo.Frame.Description := 'Example description'; LFrameInfo.Show; end; procedure TMainForm.TextButtonClick(Sender: TObject); var LFrameInfo: TFrameInfo<TTextFrame>; begin LFrameInfo := FrameStand1.New<TTextFrame>(); LFrameInfo.Frame.Text := 'Example text'; LFrameInfo.Show; end; What I did here - one method for all frames (working) function GetFrameInfo<T>: TFrameInfo<T>; begin Result := FrameStand1.New<T>(); Result.Show; end; I'm able to set via RTTI "Text" property in one frame and "Description" in other as they are strings. For simple types it easy. But let's consider there property "MainFrame", it's type is TFrameInfo<T> or TFrameInfo<TFrame>. How to set it with RTTI? Because then I want to link it in the same manner to ListView like AItem.Data[ 'freame_info' ].AsType< TFrameInfo< TFrame > >; And then by clicking to open according frame. I don't entirely understand how to make RTTI understand my TFrameInfo<TFrame >> Thanks in advance demo.zip
  13. Hi there I have read pretty a lot topics about data-aware components. There are a lot of even funny / useless examples (as examples I put here, found in internet, not mine code). Thinkg about this panel component.... Is it possible to add master-detail feature? Basically, all I need is like cached update. Short example: there are tables "Queries" and "Fields". If user adds / deletes / updates some fields, I want to save either all (both "Queries" and "Fields") or do nothing. Because if user decided to cancel editing - there is no way to do it. Is it possible? Or may be somewhere is component already with suach an option? What I can probably do for now - put all data to tlist, may be then for save I have to loop through manually... Thanks. uDBCalendarView.pas uDBPanel.pas
  14. WalkingAway

    Spring4D + DSharp = RAD Alexandria

    Some debug info. Here is error in this line, "TRttiNamedObject.Name" is nil (abstract error). Probably this is the key difference (new method in Alexandria) and cause of abstract error , but I'm not able to correct this: In Rio working as well both libraries. Hope, maybe some day DSharp will be compatible with Springs 2.
  15. WalkingAway

    Spring4D + DSharp = RAD Alexandria

    thanks Or at least he makes v1 compatible with Alexandria
  16. WalkingAway

    TFruit class moved to component

    Let say I have this class, TFruit: unit MyUnit; interface uses SysUtils; type TFruit = Class private color : string; protected public constructor Create(color: string); published property color: string read string end; I can make the instance rocedure TForm1.FormCreate(Sender: TObject); var banana : TFruit; begin banana := TFruit.Create('red'); Now: How I can achive the same functionality if it would possible to make component - the same TFruit and visible property color in IDE? And then if I drop component, this instance of TFRuit is made for me automatically... Is it possible? For now only I can imagine - some / any TComponent descendant and some FFruit: TFruit property... Thanks
  17. WalkingAway

    TFruit class moved to component

    Thank you guys! I have got it. Just came here to ask next level's question and saw unread messages I will check those books of course But anyway, is it possible to achieve something like this (I mean totally in IDE, design time): I have basic class TSQLBuilder and then it has property TSQLBuilderProvider - abstract, it can be let say FireDac, UniDac, AnyDac... 1) For every of them then can be setted up Query + Connection: for FD - TFDQuery and TFDConnection, for UniDAC - TUniConnection and TUniQuery and so one So far I did it through connectionString property, but it's boring as I have to build it outside this component Something similar to this - drop TSQLBuilder to the form and then there is some abstract property TSQLBuilderProvider, but if on form on f.e. TSQLBuilderProviderFD or TSQLBuilderProviderUniDac, it was possible to set it in design time. 2) Second thing: property that makes sence for one TSQLBuilder, but not usable / posible for other. For example if I chose FD as type, then there is type string property - MySQL, MSSQL or SQLite. I dont need obviously this property forTSQLBuilderProviderFireBird. Probably this option have to be hidden according to other property Thank you so much Of course, its pretty hard to make something good enough, this topic more about education I guess. Thanks again
  18. WalkingAway

    custom TTreeView

    Hello Just have created simple TTreeView based component. There are memory leaks. Reason, that New(Pointer) and then Dispose(Pointer) - second one not implemented yet. To handle this, I got to Destroy. But interesting that in Destroy method Items.Count is empty, somehow everithing is freed already... Why? Do I have to keep and track own ToDelete list for that? pas file in the attachement Thanks. myComponent.txt
  19. WalkingAway

    custom TTreeView

    Thank you so much for your answers, I will check everything. It opens my mind. Of course, probably better idea to use something available, f.e. VirtualTreeView. But I tried just for educational purpose. Thank you again. Some of mistakes were not visible for me at all...
  20. Hello. I need help. I didn't entirely understand, but the same code working with TMemo component dropped to the form and not working with dynamically created TMemo. More strangely, when I have two buttons (one for creating and one for calling recalc height of memo) - by clicking one after one - ok, but inside one (creating and updating height - not). What is the reason? Thanks. unit Unit46; interface uses System.SysUtils, System.Types, System.UITypes, System.Classes, System.Variants, FMX.Types, FMX.Controls, FMX.Forms, FMX.Graphics, FMX.Dialogs, FMX.Memo.Types, FMX.Controls.Presentation, FMX.ScrollBox, FMX.Memo, FMX.StdCtrls; type TForm46 = class(TForm) Button1: TButton; Button2: TButton; procedure Button1Click(Sender: TObject); procedure Memo1ChangeTracking(Sender: TObject); procedure Button2Click(Sender: TObject); private { Private declarations } public { Public declarations } end; var Form46: TForm46; Memo1: TMemo; implementation {$R *.fmx} procedure TForm46.Button1Click(Sender: TObject); begin Memo1 := TMemo.Create(self); Memo1.Parent := Form46; Memo1.Name := 'Memo1'; Memo1.DataDetectorTypes := []; Memo1.Lines.Clear; Memo1.Lines.Add('AAAAAAAAAAAAAA'); Memo1.ShowScrollBars := False; Memo1.OnChangeTracking := Memo1ChangeTracking; Memo1.Align := TAlignLayout.Horizontal; Memo1.EnabledScroll := False; Memo1.TabOrder := 0; Memo1.WordWrap := True; Memo1ChangeTracking(Memo1); //here is wrong Memo1.ContentBounds.Height end; procedure TForm46.Memo1ChangeTracking(Sender: TObject); begin Memo1.Height := Memo1.ContentBounds.Height + 5; end; procedure TForm46.Button2Click(Sender: TObject); begin Memo1ChangeTracking(Memo1); end; end.
  21. WalkingAway

    ChangeTracking with dynamically created TMemo ...

    I have tried, but with no success. Something like DoRealign is the place where this happens. But actually this call not helps at all... Only when I physically change something in memo, then fires this ChangeTracking ... So close, but my skills too low to solve this problem Thanks
  22. Hello I have pretty simple example here - form with list of records and then the edit form (see pictures). What if I want extra functionality - like for Country edit for example DBLookup field (through DBLookUpCombo)? How I see it: 1) Edit +Button (button inside the edit or next to edit) 2) Searchin value in lookup dataset (parameter is value from dbedit) - if not found exactly 1 record - opens form for lookupdataset for picking one from dataset 3) Searching has to be by ID or name (as I have view with calculated field '{Id} Name') 4) Button next to edit directly opens form for lookup daset Is any component for that purpose? Thanks.
  23. WalkingAway

    Marshmellow

    Not about Marshmallow, but .... Looking for some "dynamic" ORM. Makes it sense? Have some DB Wizard for adding columns "on the fly" (usable in reports, for example) But in ORM universe I have no idea how to do that. Thanks
  24. Is to make sense not to use ShowMessage inside OnClick event due to mouse cursor hang? My event works pretty well until I decided to add ShowMessage inside. After that cursor over listbox has "crossed out circle" and I have to click on listbox to get it normal. But that click itself seems not to work also. It's only happens when listbox.DargMode = dsAutomatic. Why?
×