We can use multiple models from controller but when we have to paginate by their headers and the data is from different models then we should set the URL for the headers and the response data should be placed differently.
Here we have two different Models Users, Roles in single Controller User Set Up.
User can have multiple Roles.
The User and Roles are displayed in single controller User Set Up(ex: different tabs or in different divs side-by-side). And If we want to paginator Using the Core libraries of the CakePHP It will take the default path.
The User Set Up loads both the User and Roles data by using set of different models.
Whe we set the Header with the Paginator in view we will use:
echo $this->Paginator->sort(‘first_name’,’First Name’);// this will take the default paginator controller and action of current controller from which it is called.
But the default action will again load the total User Setup page.(which we don’t want,we just want to load the Users data according to the Pagination).
Here there is 3 Step Process:
1) We should change the default controller and action to call.
2) Convert the call to AJAX call.
3)To replace the current data with the reponse Data.(User and Role Should be replaced accordingly).