问题描述
datagrids:
gates-under-location-grid:
inline_editing:
enable: true
extended_entity_name: Entity\Gate
source:
type: orm
query:
select:
- g
- l
- ancestor.id as ancestorId
- ancestor.name as ancestorName
from:
- { table: Entity\Gate,alias: g }
join:
left:
- { join: g.locations,alias: l }
inner:
- { join: Entity\LocationClosure,alias: lc,conditionType: WITH,condition: 'l.id=lc.descendant' }
- { join: Entity\Location,alias: ancestor,condition: 'ancestor=:rootLocation'}
where:
and:
- lc.ancestor=:rootLocation
bind_parameters:
rootLocation: ~
hints:
- HINT_TRANSLATABLE
columns:
name:
label: 'gate.datagrid.field.name'
align: left
locations:
label: 'gate.datagrid.field.locations'
align: left
data_name: locations
data: locations
type: twig
template: Partials/Datagrid/Gate:locations_cell_in_gate_under_location_grid.html.twig
frontend_type: html
inline_editing:
behavIoUr: enable_selected
editor:
view: oroform/js/app/views/editor/related-id-select-editor-view
view_options:
value_field_name: locations.name
placeholder: 'placeholder'
autocomplete_api_accessor:
class: oroentity/js/tools/entity-select-search-api-accessor
entity_name: Entity\Location
search_handler_name: locations
value_field_name: id
field_name: name
label_field_name: name
properties:
id: ~
view_link:
type: url
route: gate_view
params: [ id ]
update_link:
type: url
route: gate_update
params: [ id ]
sorters:
columns:
name: { data_name: g.name }
default:
name: ASC
filters:
columns:
name:
type: string
data_name: g.name
actions:
view:
type: navigate
label: 'common.grid.details'
link: view_link
icon: eye
update:
type: navigate
label: 'common.grid.edit'
icon: edit
link: update_link
options:
entityHint: 'gate.datagrid.entityhint'
export: true
entity_pagination: true
routerEnabled: false
位置单元格编辑器模板在locations_cell_in_gate_under_location_grid.html
文件中:
{% import 'OroUIBundle::macros.html.twig' as UI %}
<span class="inline-actions-element">
{% for location in value %}
<span class="tags-container">
<a href="#" title="{{ location.name }}" class="tags-container__tag-entry">
<span>
{{ location.name }}
</span>
</a>
</span>
{% endfor %}
<span class="inline-actions-element_actions inline-actions-element_wrapper" data-role="container">
{{ UI.clientButton({
'dataUrl': path('gate_locations_update',{
'gateId': record.rootEntity.id,'locationId': record.getValue('ancestorId')
}),'aCss': 'inline-actions-btn inline-actions-btn--size-s','iCss': 'fa-pencil','dataId': record.rootEntity.id,'title' : 'Edit'|trans,'label' : 'Edit'|trans,'widget' : {
'type' : 'dialog','multiple' : false,'reload-grid-name' : 'gates-under-location-grid','options' : {
'alias': 'gate_locations_update_dialog','stateEnabled': false,'dialogoptions' : {
'title' : 'gate.datagrid.under_location.locations_edit_widget.title'|trans,'allowMaximize': false,'allowMinimize': false,'width': 600,'modal': true,},}) }}
</span>
控制器动作如下:
/**
* Shows editForm,or updates Gate with given ID
*
* @Route("/locations-edit/gate/{gateId}/location/{locationId}",name="gate_locations_update",requirements={"gateId"="\d+","locationId"="\d+"})
* @Template("Gate:locations_update.html.twig")
* @ParamConverter("gate",class="Entity\Gate",options={"id" = "gateId"})
* @ParamConverter("location",class="Entity\Location",options={"id" = "locationId"})
*
* @param Request $request
* @param Gate $gate
* @param Location $location
*
* @return array|RedirectResponse
*/
public function updateLocationsAction(Request $request,Gate $gate,Location $location)
{
$form = $this->get('form.factory')
->create(GateLocationsType::class,$gate,['attr' => ['rootLocation' => $location]]);
return $this->get('oro_form.update_handler')
->update(
$gate,$form,$this->get('translator')->trans('common.processes.successful_saved'),$request
);
}
我想在内联编辑后刷新单元格,但是由于找不到任何机会,因此刷新整个datagrid会很好。
问题在于此解决方案,在存储单元格数据之后,我收到了Data loading Failed,try reloading the page. If the issue appears again please contact your administrator.
消息,并将其记录在日志文件中:
request.CRITICAL: Uncaught PHP Exception Oro\Bundle\DataGridBundle\Exception\invalidargumentexception: "Cannot bind datasource parameter "rootLocation",there is no datagrid parameter with path "rootLocation"." at vendor/oro/platform/src/Oro/Bundle/DataGridBundle/Datasource/Orm/ParameterBinder.PHP line 164 {"exception":"[object] (Oro\\Bundle\\DataGridBundle\\Exception\\invalidargumentexception(code: 0): Cannot bind datasource parameter \"rootLocation\",there is no datagrid parameter with path \"rootLocation\". at app/vendor/oro/platform/src/Oro/Bundle/DataGridBundle/Datasource/Orm/ParameterBinder.PHP:164,Symfony\\Component\\PropertyAccess\\Exception\\NoSuchPropertyException(code: 0): The key \"rootLocation\" does exist in an array. at app/vendor/oro/platform/src/Oro/Component/PropertyAccess/PropertyAccessor.PHP:435)"} []
有人可以帮忙,如何通过rootLocation参数进行刷新? 预先感谢!
解决方法
不建议使用自定义控制器来处理数据网格中的内联编辑。
请遵循Creating editable data grid cells in OroPlatform applications上的官方文档。
此外,在inline editing in the OroPlatform datagrids上有一个常规参考,您可以在其中找到有关所有现有内联编辑器选项的文档。您可以使用其中之一,而不是实施自定义的,也可以将其用作创建自己的编辑器的基础。