ngx-datatable icon indicating copy to clipboard operation
ngx-datatable copied to clipboard

Page initialization

Open MatthewTrout opened this issue 8 years ago • 7 comments

I'm submitting a ...

[ ] bug report => search github for a similar issue or PR before submitting
[x ] feature request
[ ] support request => Please do not submit support request here, post on Stackoverflow or Gitter

Current behavior N/A

Expected behavior Set the page number / initialize with a page number

Reproduction of the problem N/A

What is the motivation / use case for changing the behavior? Would be incredibly useful to be able to set the starting page of the component. I have a use case that stores various pagination settings across the lifecycle of the app, and returning to a page should restore the pagination to the state it was previously at. (I'm using server side pagination). However as far as I can tell (please correct me if I'm wrong), this is not currently possible.

UPDATE: I'm using server side pagination externalPaging, which works fine, and calls the page output as appropriate, which works fine. What I need to do is get into the table, an initial page number, such that the pagination control is initialised with this page visually. Currently if I set the start page and provide the table with the correct data, the paging control still will show page 1. I cannot see a way to initialise this paging control. There is no page input... Forgive me if I'm missing something obvious.

UPDATE WITH EXAMPLE: As a crude example: plnkr In this example pagination is emulated given the example company dataset. I'm using externalPaging. I'm attempting to demonstrate that if I initialize my page to 2 (1 zero indexed), and use this to retrieve the data, the correct data for page 2 is displayed, but that there is no way to initialize the page number in the pagination control to match this. There is no page number input. So if you click on page 2, you'll notice the content doesn't change: this is because it was already showing the data from page 2, but now show's page 2 itself having invoked (page).

Please tell us about your environment: N/A

  • Table version: 9.3.1

  • Angular version: 4.1.2

  • Browser: [all]

  • Language: [all]

MatthewTrout avatar Jul 28 '17 15:07 MatthewTrout

I don't see any reason you shouldn't be able to do this. Its up to you to set these inputs and rows to show. Can you show what you're doing if this does not work?

amcdnl avatar Aug 04 '17 13:08 amcdnl

@amcdnl thanks for response, I've updated the description.

MatthewTrout avatar Aug 07 '17 07:08 MatthewTrout

Sounds like a bug. I'll check it out. If you can create a demo for me to start with that would be helpful.

amcdnl avatar Aug 07 '17 13:08 amcdnl

Will do

MatthewTrout avatar Aug 08 '17 14:08 MatthewTrout

@amcdnl updated description with plunker example

MatthewTrout avatar Aug 09 '17 08:08 MatthewTrout

Greetings! Any update on this? I also need sometimes to go back to the view displaying the datatable and it would be great to be able to "restore" its state. Currently all I can do is to pass an 'offset' input variable and it seems to correctly set page number in the pagination but the table itself doesn't scroll to correct page. Did anyone find any workaround for this?

  • Table version: 13.1.0
  • Angular version: 6.1.0

quadracik avatar Mar 13 '19 01:03 quadracik

Hello, Any update on this? I have two solutions I resolved the issue by initially setting it to page 1 (offset = 0) and then using setTimeout (10ms) to initialize it with the required page. Not the most professional solution, but works with older versions of angular.

The other solution is using afterNextRender. Initialize the page with 1, and set the offset to the required page: constructor() { afterNextRender(() => { // offset is a signal this.offset.set(this.service.state()?.page - 1); }); }

Beni312 avatar Feb 07 '25 20:02 Beni312