adding a dynamic button on a MCGrid
i want to modify the line in the code below ($g->addColumn('button','check_out') to $g->addColumn('button','check_in') if the field instock is 'N'
This way the button calls a different function depending on if the tool is instock.
I do have the functions in the model as well already.
<?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['c开发者_C百科heck_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();
}
}
}
Look into implementation of format_button() inside "atk4/lib/Grid" and create your own function just like that. You'll also need to extend "Grid" to add this function.
You will also need to look into init_button() function which slaps jQuery UI button() function on the whole column.
精彩评论