How to rewrite yii2 function to get data from APIs and realize the pagination

Dear all,

I’m a beginner of yii2 framework. I’ve tried ActiveDataProvider in my env to access my sql database, and used GridView wiget to display data and do the pagination. Now I need to get data from APIs, and the APIs can give me the page info such as ‘page_size’, ‘page_number’ and ‘total_page’. My question is how can I rewrite ActiveDataProvider function to get data from APIs and realize the pagination function?

Or is there any other solution for my requirement?

Thanks!

Maybe this will help http://www.yiiframework.com/doc-2.0/guide-output-data-providers.html#creating-custom-data-provider

Oh, yes, there is ‘Creating Custom Data Provider’ section mentioned about my issue. I’ll try it out. Thank you very much, Bizley!

Issue solved, I referred to ‘Creating Custom Data Provider’ section to rewrite ‘prepareModels()’, ‘prepareKeys()’ and ‘prepareTotalCount’ functions. All the data can be returned successfully by the APIs. Thank you very much!