【问题标题】:How to add filter and quicksearch to ATK$ CRUD如何将过滤器和快速搜索添加到 ATK$ CRUD
【发布时间】:2011-09-18 10:53:34
【问题描述】:

我在 ATK4 中有一个看起来像这样的页面

<?php

class page_backlog extends Page
{

    function init()
    {
        parent::init();
        $p = $this;

        $logged_in_users_team = $p->api->getTeamID();
        $s = $p->add('Model_BacklogStory');
        $s->addCondition('team_id', $logged_in_users_team);
        $s->addCondition('side_task', 0);

        $crud = $p->add('CRUD');
        $c = $crud->setModel($s, null, array('description', 'backlog_ref', 'points', 'priority_no'));

        if ($c->grid) {
            $c->grid->last_column = 'points';
            $c->grid->getColumn('points')->makeSortable();
            $c->grid->addQuickSearch(array('description', 'backlog_ref'));
        }
    }

}

代码取自agiletoolkit documentation

网格显示,但点字段上的快速搜索和排序链接不显示。 而是页面顶部出现错误

C:\wamp\www\test1\page/backlog.php:16 [8] 未定义属性:Controller::$grid

第 16 行是if($c-&gt;grid){

关于我错过了什么的任何建议?

【问题讨论】:

    标签: php frameworks crud atk4


    【解决方案1】:

    是的。

    $c=$crud->setModel($s, null, array('description', 'backlog_ref', 'points','priority_no'));
    

    这使得 $c 成为一个模型,并且从这一行进一步 $c 不引用 crud。 因此使用if ($crud-&gt;grid) 或添加行$c = $crud;

    【讨论】:

    • 其实$c是一个控制器,但是由于它是透明的,所以可以作为模型使用。
    • 使用 if ($crud->grid) 给出另一个错误“尝试获取不存在字段的值:q”,这表明它没有看到模型构建的查询 - 我在更改之前尝试过它使用 $c 作为后者显示网格 - 只是不是快速搜索或排序链接
    • 我还仔细检查了模型中列出的所有四列,所以还有其他想法如何让它工作?
    • 发现后一个错误似乎与 stackoverflow.com/questions/7260290/… 有关,这似乎是 4.1 的问题,但改用 $crud 确实与 $c 有不同的效果。
    • 尝试切换到devel分支
    猜你喜欢
    • 2018-12-14
    • 1970-01-01
    • 2013-02-23
    • 1970-01-01
    • 2023-02-26
    • 1970-01-01
    • 2022-07-27
    • 2012-03-31
    • 1970-01-01
    相关资源
    最近更新 更多