toufik 2 Posted January 22, 2023 (edited) hello every one ... I'm trying pagination with SQLite database using live binding with a tlistview i did try using this guide: DB Pagination and TListView question - Databases - Delphi-PRAXiS [en] (delphipraxis.net) with some modification so i added the implement of pagination on PullToRefresh of the tlistview and work's fine . the problem that .... i want to keep the items that added to the tlistview every PullToRefresh and so on the code I used, can anyone point me to the right direction. procedure TFormMain.ListView2MouseMove(Sender: TObject; Shift: TShiftState; X, Y: Single); begin if PullToRefreshCheck then begin if (Y-RefreshPos)>40 then begin if (FDTableTask.RecordCount < lMyMaxRecordsByPage) then exit; // FDTableTask.Disconnect; FDTableTask.FetchOptions.RecsSkip := FDTableTask.FetchOptions.RecsSkip + lMyMaxRecordsByPage; FDTableTask.Open(); Label48.Text := '...تحديث'; Label48.Visible := True; Timer3.Enabled := True; PullToRefreshCheck := False; RefreshPos := 0; end else begin Label48.Text := 'u retched the end '; end; end; bandicam_2023-01-22_20-18-24-671_(1).mp4 Edited January 22, 2023 by toufik Share this post Link to post
programmerdelphi2k 237 Posted January 22, 2023 3 hours ago, toufik said: i want to keep the items that added to the tlistview every PullToRefresh and so on @toufik then, you would can try some like this: no pagination, in fact, but just increase the param used in "LIMIT" in your select ex.: 1 ... 20 = 20 records on LV 1... 40 = 20 + 20 records on LV 1... 60 = 20 + 20 + 20 .... etc... YourQUERY.Text := SELECT ... from TableXXX LIMIT "n" --> n= 20, n=40, n=60, etc... you can try use "params" in your select to change the value in "n" Quote object FDQuery1: TFDQuery Connection = FDConnection1 SQL.Strings = ( 'select * from tablex LIMIT :n') Left = 416 Top = 232 ParamData = < item Name = 'N' DataType = ftInteger ParamType = ptInput Value = Null end> YourQUERY.Last ---> go to last record on screen or any other way to show last 20 records in your LV LiveBinding use o "BindSourceDB" then you try this: "BindSourceDB1.DataSet.Last" 1 Share this post Link to post
programmerdelphi2k 237 Posted January 22, 2023 (edited) using "Dataset" (FireDac or any other) you can try this: after your "SELECT" here my sample using a EMPLOYEE Interbase db: "SELECT * FROM CUSTOMER ROWS :N " --> N = param "Integer" implementation {$R *.dfm} //type // TMyHack = class(TDBGrid); var LDBGridVisibleRows: integer; LNextRecord : integer; procedure TForm1.FormCreate(Sender: TObject); begin LDBGridVisibleRows := 10; // TMyHack(DBGrid1).RowCount; // or your LV visible items on screen!!! LNextRecord := LDBGridVisibleRows; // CustomerTable.Open; end; procedure TForm1.Button1Click(Sender: TObject); begin CustomerTable.ParamByName('N').AsInteger := LNextRecord; CustomerTable.Refresh; CustomerTable.Last; // LNextRecord := LNextRecord + LDBGridVisibleRows; // CustomerTable.MoveBy(-LDBGridVisibleRows) end; Edited January 23, 2023 by programmerdelphi2k 1 Share this post Link to post
programmerdelphi2k 237 Posted January 23, 2023 (edited) to avoid more clicks... procedure TForm1.Button1Click(Sender: TObject); begin CustomerTable.ParamByName('N').AsInteger := LNextRecord; CustomerTable.Refresh; CustomerTable.Last; // if (LNextRecord >= CustomerTable.RecordCount) then // not more records... Button1.Enabled := false; // LNextRecord := LNextRecord + LDBGridVisibleRows; // CustomerTable.MoveBy(-LDBGridVisibleRows) end; Edited January 23, 2023 by programmerdelphi2k 1 Share this post Link to post
toufik 2 Posted January 26, 2023 @programmerdelphi2k i did try it and worked fine thats alot Share this post Link to post