Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/249.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/7/user-interface/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Php 如何使用选定列对网格进行分页_Php_User Interface_Frameworks_Atk4 - Fatal编程技术网

Php 如何使用选定列对网格进行分页

Php 如何使用选定列对网格进行分页,php,user-interface,frameworks,atk4,Php,User Interface,Frameworks,Atk4,在敏捷工具包教程(Jobeet)中,我设置了快速数据模型(第3页),它与CRUD测试页面配合得很好。我试图更改test.php文件中的一行代码。问题是,当我添加分页器(代码行)时,网格中的数据消失了。这是对paginator类的限制吗?有没有一种快速的方法可以让这个自定义网格分页?谢谢 原始代码显示添加addPaginator时方法未定义错误,如下所示: $this->add('CRUD')->setModel('Category'); //$this->add

在敏捷工具包教程(Jobeet)中,我设置了快速数据模型(第3页),它与CRUD测试页面配合得很好。我试图更改test.php文件中的一行代码。问题是,当我添加分页器(代码行)时,网格中的数据消失了。这是对paginator类的限制吗?有没有一种快速的方法可以让这个自定义网格分页?谢谢

原始代码显示添加addPaginator时方法未定义错误,如下所示:

    $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
使用setSource修改的代码不显示错误,但显示空网格:

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)
    }
}
解决方案:

    $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是针对AgileToolkit4.1的,它使用的“setSource”已经过时


我认为如果用setModel替换setSource,应该可以

谢谢,这就是我开始的原因。积垢很好用,但我想做两件事。(1) 消除额外的列,只显示id、类型和位置字段,并且我希望(2)分页功能正常,除非我键入的语法错误,否则它不会工作。好的,我通过添加一个新模型创建了唯一的列,其中只包含我想从数据库显示的字段。我仍然停留在如何让addPaginator类为CRUD示例工作上,好吧,我得到了它,它比我想象的要简单。我只需要$jobCRUD->grid->addPaginator(3):)谢谢