Bug exporting table view

GC Enterprise v3.0.13
mySql 8 DB

What I want to do is to show some data on a webpage but when exporting into xls add more data from other tables.
This is a simplified example of what I’m trying to do

Table A
columns A, B, C, D

MySQL View V
columns A, B, C, D from table A
columns E, F, G from table B

        $current_state = $crud->getState();

        if ( ($current_state == 'Export') || ($current_state == 'ExportPdf') || ($current_state == 'Print') ) {
            $field_list = array('A','B','C','D','E','F','G');
        } else {
            $field_list = array('A','B','C','D');


The problem is that in the mysql_view export I’ve got only the fields that are coming from table_a (so in this example A, B, C, D and not E, F, G)

If just for testing I change my code and in the main page I show a random table_b with fields completely different from the view, the export of the view is correct

         } else {
            $field_list = array('X','Y','Z');

the same page worked fine on GCE 2.x


Hello @Phil ,

Yes currently at the export level we are also sending the visible columns which we wasn’t sending before (on version 2). If you want to bypass this you will need to use replaceState instead. More specifically you can create a custom state that will look like this:

use GroceryCrud\Core\State\ExportState;
use GroceryCrud\Core\State\StateInterface;

class CustomExportState extends ExportState implements StateInterface {
    public function getStateParameters() {
        $stateParameters = parent::getStateParameters();

        $stateParameters->visible_columns = null;

        return $stateParameters;

and add it to your code like this:

// Don't forget to include the file at the top

$exportState = new CustomExportState($crud);
$crud->replaceState('Export', $exportState);

The above code will replace the default Export state and instead always having the visible_columns = null. That means that it will show all the columns in export and you will have the desired results.


1 Like

thank you, will try that!