-
Content Count
332 -
Joined
-
Last visited
-
Days Won
1
Everything posted by Serge_G
-
Delete a ListView Item together with its livebinding DB record.
Serge_G replied to Tang's topic in FMX
Hi, No, the image I post was a "classic" ImageListItemRightButton Item appearance (with TextButton visible) , and ImageListItemRightButtonDelete for the ItemEdit appearance. The "access error", I got it when I try to use a ListView1.DeleteItem(AItem.Index); beforehand declared as an helper (only way I found to raise OnDelete/Ondeleting event with touch input unavailable. TListViewHelper = class helper for TListView public function DeleteItem(const ItemIndex: Integer): Boolean; end; { TListViewHelper } function TListViewHelper.DeleteItem(const ItemIndex: Integer): Boolean; begin inherited; end; And using the OnButtonClick event of TListView (guilt, the TListItem.MouseUp event) Using the OnItemClick to use DeleteItem procedure TForm1.ListView1ItemClick(const Sender: TObject; const AItem: TListViewItem); begin ListView1.DeleteItem(AItem.Index); end; I have no "access error" Sorry, it was an "argument out of range" not an "access violation" (guilty TListItemView.GetObject). My test (on Android), shows me that if there is only one item (the one to delete) this exception does not raise. Yes, perhaps a bypass but in wich event ? -
Delete a ListView Item together with its livebinding DB record.
Serge_G replied to Tang's topic in FMX
So, I test this on Android. @Tang I can submit you this solution Add a private variable (in my code key : integer;) procedure TForm1.ListView1DeleteItem(Sender: TObject; AIndex: Integer); begin if FDMemtable1.Locate('id',key) then fdmemtable1.Delete; // delete the record end; procedure TForm1.ListView1DeletingItem(Sender: TObject; AIndex: Integer; var ACanDelete: Boolean); begin key:=listView1.Items[aIndex].Tag; // get the key to delete ACandelete:=true; end; But, yes, there is one, I think there is a bug I wrote in the prior post : -
Delete a ListView Item together with its livebinding DB record.
Serge_G replied to Tang's topic in FMX
Ok, but I try this on a windows pc how can I "simulate" this wipeleft ? On another hand, with a "classic" windows app (D11 Alexandria). I found that Deleting last item of the list raise an 'access violation' ! procedure TForm1.LinkListControlToField1FilledListItem(Sender: TObject; const AEditor: IBindListEditorItem); begin (AEditor.CurrentObject as TListItem).Tag := FDTable1.FieldByName('ID').AsInteger; end; procedure TForm1.ListView1ButtonClick(const Sender: TObject; const AItem: TListItem; const AObject: TListItemSimpleControl); begin if FDtable1.Locate('Id',AItem.Tag) then FDtable1.Delete; end; -
Delete a ListView Item together with its livebinding DB record.
Serge_G replied to Tang's topic in FMX
Hi, Well, I don't understand the goal, I never use this DeletingItem method, but I will investigate. So to be clear : You have a TListView filled with livebindings, how do you : A gesture, I think, but the code? (I am not a gesture expert) Sorry to disappoint, but I'm not that far (I have not encountered this need in my professional life) -
Please read all my post before posting this! I forgot nothing, you don't follow my steps. You miss the : It was an example, not involving date format. And this is SGBD dependent. So, it's not your field MyDateTime which is involved in the filter I wrote, but a computed column I named c_date, computed column you have to add to your table. You jump to a bad conclusion. Filter expression is not preprocessed I think, so you can't use {fn CONVERT(mydate,DATE)}
-
I think the problem is deeper. Using a FDquery (with parameter) instead of FDTable is for me the best solution, assuming your SGBD is MySQL SELECT * FROM mytable where DATE(MyDateTime)=:paramdate by then instead of a filter building and activating you only have to write something like FdQuery.Open('',[AdvDateTimePicker2.Date]); Contraction of fdquery.Close; fdquery.prambyname('paramdate').asDateTime:= AdvDateTimePicker2.Date ; fdquery.Open; Note to avoid flickering, surround the code with a fdQuery.DisableControls / Fdquery.EnableControls Another way if you want to use FDtable and Filter is to add to your DBtable (MySQL I assume) a generated column for example ALTER TABLE mytable ADD c_date integer AS (YEAR(mydate)*10000+MONTH(mydate)*100+DAY(mydate)) now you can use this computed column for your filter var dd,mm,yy : word; begin decodedate(advdatetimePicker2.date,yy,mm,dd); fdtable.filtered:=false; fdtable.filter:=Format('c_date=%d',[yy*10000+mm*100+dd]); fdtable.filtered:=true;
-
If it's a vote I use Flamerobin (light and open source) for all quick jobs including backup/restore, extracting data and more For design purpose (very rare) I used others *DBeaver (not so fine for firebird) but I appreciate ER Diagrams You can have a list of third party firebird tools here Do my Interbase reviews have anything to do with your choice? Keep in mind that some functionality of Interbase don't exist in Firebird (thinking about column crypto for example)
-
Yes, this is fine, I am a Firebird addict, but what if you want to migrate you Firebird App to mobiles (Androïd or IOS ?) Firedac can't do this ! Ok, there are others third-party components (ANyDac, ZEOSDBO) but keep this fact in mind. By the way, deploying Firebird on Androïd is a little messy
-
Hi, The goal, I have a text file with words and I want to export in a FDMemTable words with length between 4 and 12 ? I don't know how to get the value in onWriteRecord event, is there a way to ? I can get the value in the OnWriteValue one but fired after onWriteRecord it's unusefull. Any hints (not involving a localsql DELETE)
-
OK, found it! I need mappings and then my "filter" works procedure TDataModule2.FDBatchMove1WriteRecord(ASender: TObject; var AAction: TFDBatchMoveAction); var m : String; begin AAction:=TFDBatchMoveAction.paInsert; m:=FDBatchmove1.Mappings[0].ItemValue; accept:=(Length(m)>=4) AND (Length(m)<=12); if not Accept then AAction:=TFDBatchMoveAction.paSkip; end; My file text need a first line =column definition. I just have an encoding problem to solve (attached my file) and as you can see on image I have some problems like these zygopétale, zygopétales liste_de_mots.francais.frgut.txt
-
I disagree, it's entirely dependent on SGBD used Ok but you can use formatsettings function StrToDate(const S: string; const AFormatSettings: TFormatSettings): TDateTime;
-
Ah, I knew I faced this GetItemRect somewhere ! It was when I compare the new VCL TControlList to FMX.TListView. In fact, I was deploring the lack of the method (not lack but private one) GetItemRect (I found in FMX.TListview) in the VCL.TControlList Was not so old finally, but other context . (webinaire sur TControlList partie sur le dragdrop) I quickly check and "joy" got the same results No mousemove event will fire, I think. And tracking the movement of the finger should be a real challenge
-
Hi, I have to put water in my wine even though it's a wine heresy I just read that the interbase 2020 update 2 allows recursive CTEs https://docwiki.embarcadero.com/InterBase/2020/en/What's_New_in_InterBase_2020_Update_2 so I do a first try (with firebird) not a good one SQL but as first attempt not so bad WITH RECURSIVE R AS (SELECT CUSTNO,1 AS LNo,Item,Price FROM TABLE_1 UNION all SELECT r.CUSTNO,r.LNo+1,Item,Price FROM R WHERE r.LNo< (SELECT COUNT(*) LINES FROM TABLE_1 WHERE CUSTNO=r.CUSTNO) ) SELECT CUSTNO,LNO,item,price FROM r Give me a first look, not a good one but an approximation
-
Note : in case of headers/footers a loop in the items till item index shall certainly do the job. My question : what event will you used to detect drag mode ?
-
I don't found the source I had in mind, but ... If there are no headers or footers procedure TForm1.ListView1ItemClick(const Sender: TObject; const AItem: TListViewItem); begin if AItem.Purpose=TListItemPurpose.None then begin memo1.Lines.Clear; memo1.Lines.Add('Item width '+(Listview1.width).ToString); memo1.Lines.Add('real Item width '+(Listview1.width-Listview1.ItemSpaces.Left-ListView1.ItemSpaces.Right).ToString); memo1.Lines.Add('Item Height '+Listview1.ItemAppearance.ItemHeight.toString); memo1.Lines.Add('real Item height '+(Listview1.ItemAppearance.Itemheight-Listview1.ItemSpaces.top-ListView1.ItemSpaces.bottom).ToString); memo1.Lines.Add('cursor '+Listview1.ScrollViewPos.ToString); memo1.Lines.Add(' Item toppos in list '+(AItem.index*Listview1.ItemAppearance.ItemHeight-Listview1.ScrollViewPos).ToString); memo1.Lines.Add(' real Item toppos in list '+(AItem.index*Listview1.ItemAppearance.ItemHeight- Listview1.ScrollViewPos+Listview1.ItemSpaces.top).ToString); end; end; With this, it's easy to make a bitmap extracted from ListView1.MakeScreenShot like this procedure TForm1.ListView1ItemClick(const Sender: TObject; const AItem: TListViewItem); var aBitmap : TBitmap; rect : Trect; begin if AItem.Purpose=TListItemPurpose.None then begin Rect:=TRect.Create(TPoint.Zero); Rect.Left:=Trunc(ListView1.ItemSpaces.Left); Rect.Top:=trunc(AItem.index*Listview1.ItemAppearance.ItemHeight-Listview1.ScrollViewPos+Listview1.ItemSpaces.top); Rect.Right:=Rect.Left+Trunc(Listview1.width-ListView1.ItemSpaces.Right); Rect.Bottom:=Rect.Top+Trunc(Listview1.ItemAppearance.Itemheight-ListView1.ItemSpaces.bottom); aBitmap:=TBitmap.Create; try aBitmap.Width:=Rect.Width; abitmap.Height:=Rect.Height; aBitmap.CopyFromBitmap(Listview1.MakeScreenshot,Rect,0,0); aBitmap.SaveToFile('itemtest.bmp'); finally abitmap.Free; end; end; end; result : Ok, I just forget to discount Scrollbar width, but that's the idea
-
Yes, even if I don't remember how I proceed. I will look for in my ('old') sources code tests. I remember there are some private properties but, but these memories are polluted by more recent tests on VCL.TControlList (sorry) As soon as I find these sources, I come back.
-
Well, I install Interbase and was rather disappointed! No context variables (a bypass : using a temporary table) nor windows functions . I don't investigate for Recursive CTE, but I am afraid there is not. How can that be possible as of today? I understand more Ann Harrison mother of Interbase/Firebird point of view. As quick as I install Interbase, I desinstall it 😖 really disappointed. I have no doubt there are good things in Interbase but my way is now Firebird (event if missing some crypto columns)
-
CTE, ok, but windows functions ? I am really disappointed if Interbase don't applies new SQL standard. Time is the key word, if I have some in future week I will install manually (because of 3050 port) Interbase 2020 Delphi version just to check what's new But there are some comparisons available (not commercial Embarcadero ones) https://db-engines.com/en/system/Firebird%3BInterbase or you can read https://ib-aid.com/en/articles/differences-between-firebird-and-interbase/ vs https://www.embarcadero.com/fr/products/interbase/compare/interbase_firebird And make a choice Well I do that years ago and had no problem with
-
Well, with Firebird it is, using variable context (old way). I do not remember if Interbase had this capacity (guess yes) P.S. By the way, what is your Interbase version ? SELECT CUSTNO, rdb$get_context('USER_TRANSACTION', 'row#') as LINENO, rdb$set_context('USER_TRANSACTION','row#', coalesce(cast(rdb$get_context('USER_TRANSACTION', 'row#') as integer), 0) + 1), ITEMNO, PRICE FROM table-1 ORDER BY CUSTNO But you need to add some context variable to check and reset to 1 when changing of CUSTNO New ways - Recursive Common Table Expression (I will not expand because best way is below) - Windows function SELECT CUSTNO, ROW_NUMBER() OVER (partition by CUSTNO) LINENO, ITEM, PRICE FROM TABLE_1 ORDER BY CUSTNO I suggest you to search in Interbase (version ?) documentation with these two terms By the way, I suggest you a best way to ask a SQL question : add a script CREATE TABLE table_1 ( CUSTNO INTEGER NOT NULL, ITEM CHAR(2), PRICE NUMERIC(10,2) ); INSERT INTO TABLE_1 VALUES (1,'AA',100); INSERT INTO TABLE_1 VALUES (1,'BB',150); INSERT INTO TABLE_1 VALUES (2,'AA',100); INSERT INTO TABLE_1 VALUES (2,'CC',200); INSERT INTO TABLE_1 (CUSTNO, ITEM, PRICE) VALUES ('3', 'BB', '150.00'); INSERT INTO TABLE_1 (CUSTNO, ITEM, PRICE) VALUES ('3', 'AA', '100.00'); INSERT INTO TABLE_1 (CUSTNO, ITEM, PRICE) VALUES ('3', 'CC', '200.00'); and then the expected result (ok, here I cheat it's the result of the windows function SQL using the data I used
-
What if you use a trigger BEFOREUPDATE on table Master ?
-
I don't have any Apple devices but on Androïd OnItemClick works fine. for IOS : what about onTap or Gesture management
-
My preference goes to Grid rather than StringGrid, but I prefer a ListView Agree sjordi, VCL components are poor if you compare. i.e a VCL app use Tpanel, a FMX app will use Layout or TRectangle
-
IMHO if your listview only have items not resized you can use ScrollViewPos property and perhaps the ScrollViewChange event var first, last : integer; begin first:=Trunc(listview1.ScrollViewPos/listview1.ItemAppearance.ItemHeight); Last:=First+Trunc(ListView1.Height/listview1.ItemAppearance.ItemHeight); memo1.lines.add(Format('First %d Last %d',[first,last])); If you have a TSearchbox visible I think it's easy to take care of it (using Searchbox unit to get the height) If you have groups or variable height items this should be harder but still using ScrollViewPos I think it's playable, you "just" have to calc from top, cumulate all items height till reaching ScrollViewPos for first and ScrollViewPos+ListView.Height for last
-
Hi, Well, logic, yes. Depending on the REST API server function. On another side a TListview (livebinded) for only 10 records a VerticalScrollbox filled by code should be a good alternative, IMO getting previous page and next page (30 records) during thread process should be better
-
FMX TListView with dynamicappearance. Create progress bar as bitmap.
Serge_G replied to skyzoframe[hun]'s topic in FMX
Hi Sorry but, I think we don't play in the same playground. For me, a TListView is used with Livebindings to fill it with data coming from a data source (table, query or list of Object). You use it like a TListBox! With a TListBox it's easy to put in a style whatever you want (in this case a text and a progress bar). By the way, your code is more for this kind of component, Create a style (layout, ttext, progressbar) just to adapt your code in the "for FR in FArray do" loop set the style of the created item item.stylelookup:='mystyleprogress' insert an item.applystylelookup change access to the objects of the item- 12 replies
-
- dynamicappearance
- tlistview
-
(and 2 more)
Tagged with: