0

I have read in the ag-Grid documentation that ag-Grid is destroyed automatically since it is linked with AngularJS life-cycle.

But I have a need to reload the ag-Grid's former state (such as its page number, page size, sorted column, sort, checked rows)

How do I do this?

HDJEMAI
  • 9,436
  • 46
  • 67
  • 93
kimondoe
  • 567
  • 2
  • 9
  • 27
  • You need to read all that data from grid api and store them in a service. When you recreate the ag grid, shape your grid again using grid api and data in the service. If you give more details about your scenario perhaps we can find another solution. – Sefa Oct 10 '16 at 07:00
  • I have retrieved the data. but how do I set them in ag-grid? specifically the page number? – kimondoe Oct 10 '16 at 07:16
  • I also tried to store the data via service. but the service is also recreated and the stored data has been wiped. How do I properly set it via service? – kimondoe Oct 10 '16 at 08:12
  • Service must be singleton, so it won't be wiped out. I'm searching about setting page number on ag-grid. Looks like it's not supported by grid api itself. – Sefa Oct 10 '16 at 08:13
  • I made the service via injectable, yet its constructor is called many times. 1st one I visited the component with the service, then I visited another route, then I visited again the 1st component, its constructor is called again, wiping my data. how do I do this properly? – kimondoe Oct 10 '16 at 08:20
  • see http://stackoverflow.com/questions/33598153/angular-2-whats-the-best-way-to-store-global-variables-like-authentication-tok – Sefa Oct 10 '16 at 08:21
  • From what I've read from Grid API, I have not seen any exposed property or function to get the data source. there is only this.gridOptions.api.setDatasource(datasource). Is there a way to get the datasource from the gridOptions? – kimondoe Oct 11 '16 at 01:45

0 Answers0