Jump to content

Pagged grid (question), being on the last entry on the first page on the onScroll event switch to the next one


Skyp

Recommended Posts

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)

Link to comment
Share on other sites

 

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:

image.thumb.png.7af21859e311274810e82e576677a54a.png

Again scroll: 

image.thumb.png.25c66334837453615435a3a185ec4268.png

 

how to do it?

 

 

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...