是否有选项只导出杂货杂货中的两列.我不想导出所有列


Is there any option to export only two columns in grocery-crud.. i don't want to export all columns

是否存在只导出杂货店杂货中的两列的选项?我不想导出所有列

正确的方法是使用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);
}