是否有任何选项只能在杂货店中输出两列。我不想导出所有列。
答案 0 :(得分:2)
正确的方法是使用getState()
方法
$state = $crud->getState();
if ($state == 'export' || $state == 'print') {
$crud->columns('first_name','last_name','email');
} else {
$crud->columns('first_name','last_name','email','phone','city','country');
}
您可以在下面找到完整的代码示例:
function example1()
{
$crud = new grocery_CRUD();
$crud->set_table('customers');
$crud->set_subject('Customer');
$crud->required_fields('first_name', 'last_name','email');
$state = $crud->getState();
if ($state == 'export' || $state == 'print') {
$crud->columns('first_name','last_name','email');
} else {
$crud->columns('first_name','last_name','email','phone','city','country');
}
$output = $crud->render();
$this->_example_output($output);
}