0

I am using Ag-grid in my React app, I need to trigger an action when the user reaches the 90% of the rows visibles (no matter if they made scroll or click the 'next' button). How can I know that? which event should I use?

My thoughts are that everytime that the user reaches the 90% of the rows loaded then I will trigger the defined action. Thank you very much.

EDIT:

<AgGridReact
          columnDefs={this.state.columnDefs}
          rowData={this.props.rowData }
          ViewportChangedEvent={this.onScroll.bind(this)}
          enableSorting
          enableFilter
          showToolPanel
          pagination
          paginationAutoPageSize
          singleClickEdit
          sizeColumnsToFit
          enableColResize
          onGridReady={this.onGridReady}
          rowHeight={48}
          onSomeEvent={some.handler}
          />

That's what I have and it's diplaying the data correctly, now I need an event onSomeEvent={some.handler} that allow me to know which is the row that he is seeing to know when he reaches the 90% of the total rows that are loaded.

Sredny M Casanova
  • 4,735
  • 21
  • 70
  • 115
  • Hi! Please provide [mcve] of what you have tried so far. – bennygenel Sep 26 '17 at 13:08
  • @bennygenel Hi! I added some code, thank you – Sredny M Casanova Sep 26 '17 at 14:05
  • You can use [`bodyScroll`](https://www.ag-grid.com/javascript-grid-events/?framework=react#gsc.tab=0) event to determine how far you are from the end I believe. – bennygenel Sep 26 '17 at 14:10
  • @bennygenel yes, Indeed I tried with that event, but was only triggering on scrolling and not when the user clicked on "next","last" or "previous button". So, am starting to believe that I should use paginationChanged – Sredny M Casanova Sep 26 '17 at 14:28
  • 1
    If you are using pagination too you need to combine 2 events and create a logic to check whats the users current position. It can be kinda complicated. – bennygenel Sep 26 '17 at 14:35
  • @SrednyMCasanova Hey, how did you try with that bodyScroll event? I found it in their documentation but didn't find the actual exposed function in their code. – chaonextdoor Apr 17 '18 at 16:55

0 Answers0