【问题标题】:Is there any option to export only two columns in grocery-crud.. i don't want to export all columns是否有任何选项可以仅导出杂货店中的两列..我不想导出所有列
【发布时间】:2014-05-08 12:09:17
【问题描述】:

是否有任何选项可以只导出杂货店中的两列。我不想导出所有列。

【问题讨论】:

  • 我创建了答案。现在。 if ($this->uri->segment(3) == "export") { $crud->columns('code','name'); } else{ $crud->columns('code','name','email','phone'); }

标签: php codeigniter grocery-crud


【解决方案1】:

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

【讨论】:

  • 这给了我错误使用未定义的常量状态 - 假定为“状态”
猜你喜欢
  • 1970-01-01
  • 2020-03-29
  • 2011-02-14
  • 1970-01-01
  • 2017-09-04
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多