In the Agile Toolkit Tutorial (Jobeet), I setup the quick data model (Page 3) and it looks nice with the CRUD test page. I tried to change a line of code in the test.php file. The problem is when I added the paginator, line of code, the data in the grid disappeared. Is this a limitation to the paginator class? Is there a quick way to get this custom grid paginated? Thanks.
Original Code displays method not defined error when adding addPaginator as shown below:
$this->add('CRUD')->setModel('Category');
//$this->add('CRUD')->setModel('Job');
$jobCRUD=$this->add('CRUD');
$jobCRUD->setModel('Job');
$jobCRUD->addPaginator(3); //This line causes an method not defined error
Modified code using setSource doesn’t display an error but displays an empty grid:
class page_test extends Page {
function init(){
parent::init();
//$this->add('CRUD')->setModel('Category'); //Not needed for my example
$grid=$this->add('Grid');
//$grid->setModel('Job'); //Removed this to show custom columns
$grid->addColumn('id');
$grid->addColumn('type');
$grid->addColumn('position');
$grid->setSource('job');
$grid->addPaginator(3); //Added this to paginate the results (doesn't work & removes data)
}
}
Solution:
$this->add('CRUD')->setModel('Category');
//$this->add('CRUD')->setModel('Job');
$jobCRUD=$this->add('CRUD');
$jobCRUD->setModel('Job');
$jobCRUD->grid->addPaginator(3); // This fixed the paginator
Jobeet is for Agile Toolkit 4.1 and uses “setSource” which is obsolete.
I think if you replace setSource with setModel it should be OK.