As I identify what action was taken in the pagination

Hello!

Is there any way to detect which button the user gave him? If to the previous or next button?

I appreciate the help

Hello,

There is no direct way to determine which way the page changed: next or previous page. However, you can determine which direction by using the selectedPageIndex property of the table.

Here are the steps:

  1. Create a temp state, default to 0
    image

  2. Create a JS query with the following code, feel free to change for your context.
    image

    if (table1.selectedPageIndex > currentSelectedPageIndex.value) {
      // page moved to the right
      // next page clicked
      console.log("next page");
    } else {
      // page moved to the left
      // previous page clicked
      console.log("previous page");
    }
    
    console.log(table1.selectedPageIndex);
    await currentSelectedPageIndex.setValue(table1.selectedPageIndex);
    
  3. Create a event handler in your table and trigger the JS query in #2
    image

And that will do it, once page changed you can tell if it was next page or previous, even if page number was changed. Note for manual page number, if # is the same then the event won't trigger.

page changed

Hope that helps

1 Like

@lamh_bytecode.io Just what I needed, thanks for your help!

1 Like