Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add EventDispatcher DataGrid #2

Closed
blacxi opened this issue Dec 14, 2017 · 1 comment
Closed

Add EventDispatcher DataGrid #2

blacxi opened this issue Dec 14, 2017 · 1 comment

Comments

@blacxi
Copy link

blacxi commented Dec 14, 2017

Hello !

For a project, i needed to display different columns depending of the user role on the family listing.
I created a EventDispatcher on the getDataGrid() method to do this.

    public function getDataGrid(string $code): DataGrid
    {
        $dataGrid = null;

        if (!array_key_exists($code, $this->dataGrids)) {
            $dataGrid = $this->buildDataGrid($code);
        } else {
            $dataGrid = $this->dataGrids[$code];
        }

        $this->eventDispatcher->dispatch(DataGridEvent::DATA_GRID_INITIALIZED, new DataGridEvent($dataGrid));

        return $dataGrid;
    }

And in my listenner I could change the DataGrid (columns and sortables) before to use it and render the views. I think it would be useful to have the EventDispatcher natively in the DataGrid.

What do you think about this solution ?

Regardes ! thx

@VincentChalnot
Copy link
Owner

Hello,
I don't want to implement any event for this specific need, this method is easily extendable in the final controller in the project.
Just declare a specific controller for your need.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants