Skyp Posted December 20, 2023 Share Posted December 20, 2023 Hi, everybody. UniDBGrid, with a PageSize:=25 setting in a TDataSet of 50 records Being on the 25th line of the first page and pressing the down button (or scrolling the mouse) I want to get to the next page (the first line). Being on the first line of the 2nd page, pressing the button on the keyboard (or scrolling the mouse) up to get to the last line of the first page. Has anyone done this? (Paging must be enabled - i.e. it's not about infinity scroll) Quote Link to comment Share on other sites More sharing options...
Sherzod Posted December 20, 2023 Share Posted December 20, 2023 Hello, It seems there was a solution on the forum. Quote Link to comment Share on other sites More sharing options...
Skyp Posted December 20, 2023 Author Share Posted December 20, 2023 So I didn't find it =(( Quote Link to comment Share on other sites More sharing options...
Sherzod Posted December 20, 2023 Share Posted December 20, 2023 12 minutes ago, Skyp said: So I didn't find it =(( ? Quote Link to comment Share on other sites More sharing options...
Skyp Posted December 22, 2023 Author Share Posted December 22, 2023 The solution does not work. When switching to the last entry in the page, switching occurs (immediately and not when pressing down again). But I corrected this as follows: 1.We add two fields to the grid class (if there are several of them, then for each) (in section private, strict private): TmyClass=class(TUniForm) ... strict private FlastRecNoPrev, FlastRecNoNext: Integer; ... end; 2. We add processing to the onKeyDown - DBGrid event (next code): if ((Sender as TUniDBGrid).WebOptions.Paged) and ((Key = VK_DOWN) or (Key = VK_Up)) then begin if (Key = VK_DOWN) and (((Sender as TUniDBGrid).DataSource.DataSet.RecNo mod (Sender as TUniDBGrid).WebOptions.PageSize) = 0) and (not(Sender as TUniDBGrid).DataSource.DataSet.Eof) then begin if FlastRecNoNext <> (Sender as TUniDBGrid).DataSource.DataSet.RecNo then FlastRecNoNext := (Sender as TUniDBGrid).DataSource.DataSet.RecNo else begin (Sender as TUniDBGrid).DataSource.DataSet.Next; FlastRecNoNext := (Sender as TUniDBGrid).DataSource.DataSet.RecNo; FlastRecNoPrev := FlastRecNoNext; end; end; if (Key = VK_Up) and ((((Sender as TUniDBGrid).DataSource.DataSet.RecNo - 1) mod (Sender as TUniDBGrid).WebOptions.PageSize) = 0) and (not(Sender as TUniDBGrid).DataSource.DataSet.bof) then begin if FlastRecNoPrev <> (Sender as TUniDBGrid).DataSource.DataSet.RecNo then FlastRecNoPrev := (Sender as TUniDBGrid).DataSource.DataSet.RecNo else begin (Sender as TUniDBGrid).DataSource.DataSet.Prior; FlastRecNoPrev := (Sender as TUniDBGrid).DataSource.DataSet.RecNo; FlastRecNoNext := FlastRecNoPrev; end; end; exit; end; 3.We add processing to the onSelectionChange - DBGrid event (code): FlastRecNoNext := (Sender as TUniDBGrid).DataSource.DataSet.RecNo; FlastRecNoPrev := FlastRecNoNext; That's good, thanks for the tip. On 12/20/2023 at 7:38 PM, Sherzod said: ? What should I do with scrolling (mouse scroll -grid)? (when the user scrolls down the page (to the end) and tries to scroll down again, you need to switch the page) *Down - up Example: Again scroll: how to do it? Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.