This topic contains 2 replies, has 2 voices, and was last updated by Alexander 6 years ago.
- Topic
Hi,
I’ve created a simple datagrid by following this article
Now I have a problem with datagrids.yml because the view and update needs a custom parameter for the route:
In the symfony-log I get the following error message1Getting grid data failed. Context: { "exception": "Exception(Symfony\\Component\\Routing\\Exception\\InvalidParameterException): Parameter \"block_name\" for route \"education.classroom.test_update\" must match \"[^/]++\" (\"\" given) to generate a corresponding URL." }datagrids.yml:
1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950tests-grid:source:acl_resource: education.classroom.test_indextype: ormquery:select:- t.id- t.name- t.averagefrom:- { table: EducationBundle:Test, alias: t }where:and:- t.block = :blockIdbind_parameters:- blockIdcolumns:name:label: Testdescription:label: Beschreibung:author:label: Erstellt von:properties:id: ~update_link:type: urlroute: education.classroom.test_updateparams:block_name: block_nameid: iddelete_link:type: urlroute: education_api_delete_testparams:- idactions:update:type: navigatelabel: Updatelink: update_linkicon: editacl_resource: education.classroom.test_updatedelete:type: deletelabel: Deletelink: delete_linkicon: trashacl_resource: education.classroom.test_deleteindex.html.twig:
123456789101112131415161718192021222324252627282930313233343536{% extends 'OroUIBundle:actions:index.html.twig' %}{% import 'OroUIBundle::macros.html.twig' as UI %}{% set pageTitle = 'Tests'|trans %}{% block navButtons %}{% if is_granted('education.classroom.test_create') %}<div class="btn-group">{{ UI.addButton({'path': path('education.classroom.test_create', {'block_name': block.name}),'entity_label': 'Test'|trans}) }}</div>{% endif %}{% endblock %}{% block content_datagrid %}{% if gridName is defined %}{% if gridScope is defined %}{% set gridName = oro_datagrid_build_fullname(gridName, gridScope) %}{% endif %}{% set params = {'blockName': block.name, 'blockId': block.id} %}{% set renderParams = {'enableFullScreenLayout': true,'enableViews': true,'showViewsInNavbar': true,'filtersStateElement': '.filters-state-view-container'}|merge(renderParams|default({})) %}{{ dataGrid.renderGrid(gridName, params, renderParams) }}<script type="text/javascript">require(['orosync/js/content/grid-builder'], function (GridTagBuilder) {GridTagBuilder.allowTracking({{ gridName|json_encode|raw }});});</script>{% endif %}{% endblock content_datagrid %}I’ve also tried to pass the parameters in a Event Listener but it throws the same error
TestGridListener.php:
123456789101112131415161718192021222324252627282930313233<?phpnamespace XTAIN\EducationBundle\EventListener;use Oro\Bundle\DataGridBundle\Datagrid\Common\DatagridConfiguration;use Oro\Bundle\DataGridBundle\Datagrid\ParameterBag;use Oro\Bundle\DataGridBundle\Event\BuildBefore;class TestGridListener{/*** @param BuildBefore $event*/public function onBuildBefore(BuildBefore $event){$datagrid = $event->getDatagrid();$this->applyFilters($event->getConfig(), $datagrid->getParameters());}/*** @param DatagridConfiguration $config* @param ParameterBag $parameters*/protected function applyFilters(DatagridConfiguration $config, ParameterBag $parameters){$blockName = $parameters->get('blockName', []);$blockId = $parameters->get('blockId', []);$datagridParametersUp = $config->offsetGetByPath('[properties][update_link][params]', []);$datagridParametersUp['block_name'] = $blockName;$datagridParametersUp['blockId'] = $blockId;$config->offsetSetByPath('[properties][update_link][params]', $datagridParametersUp);}}
The forum ‘OroPlatform – How do I? Questions’ is closed to new topics and replies.