Php 在MCGrid上添加动态按钮

Php 在MCGrid上添加动态按钮,php,atk4,Php,Atk4,如果instock字段为“N”,我想将下面代码中的行($g->addColumn('button','check_out')修改为$g->addColumn('button','check_in') 这样,该按钮根据刀具是否为instock调用不同的函数 我已经在模型中有了这些函数 <?php class page_index extends Page { function init(){ parent::init(); $page=$this;

如果instock字段为“N”,我想将下面代码中的行($g->addColumn('button','check_out')修改为$g->addColumn('button','check_in')

这样,该按钮根据刀具是否为instock调用不同的函数

我已经在模型中有了这些函数

<?php
class page_index extends Page {
    function init(){
        parent::init();
        $page=$this;

        $g=$page->add('MVCGrid');

        $tool=$g->setModel('Tools',
            array('number','name','description','instock'));

        $g->addColumn('button','check_out');
        $g->addPaginator(20);
        $g->dq->order('number asc');

        if($_GET['check_out']){
            $tool->loadData($_GET['check_out']);
            $tool->check_out()->update();
            $g->js()->reload()->execute();
        }
        if($_GET['check_in']){
            $tool->loadData($_GET['check_in']);
            $tool->check_in()->update();
            $g->js()->reload()->execute();
        }       
    }
}

研究“atk4/lib/Grid”中format_button()的实现,并创建您自己的函数。您还需要扩展“Grid”来添加此函数


您还需要研究init_button()函数,它将jQuery UI button()函数放在整个列上。

研究“atk4/lib/Grid”中format_button()的实现,并创建您自己的函数。您还需要扩展“Grid”来添加此函数

您还需要研究init_button()函数,它将jQuery UI button()函数放在整个列上