Completed
Last Updated: 05 Aug 2020 07:26 by ADMIN
Release 2.16.0
Gary
Created on: 19 Feb 2020 06:47
Category: Grid
Type: Feature Request
8
Event when hierarchy in the grid is collapsed or expanded

I am editing parent and child records in the hierarchy grid.  I can edit parent and child records without issue.  The only problem I have now is this; when I click edit on a child record, then collapse the parent, the edit of the child record is lost or cancelled but there is no event I can see to use to put things back in non-edit mode.

I enable buttons and links in non-edit (view) mode and disable them when editing a record.

So,  is there an event or some way to know the user is collapsing or expanding a parent record?

 

Thank you,

3 comments
ADMIN
Marin Bratanov
Posted on: 19 Feb 2020 18:11

Indeed, Gary, there are flags outside of the detail template that act as state that will be maintained across expand/collapse.

I am attaching here a sample app I made for you that shows the concept of a workaround:

  • in the HierarchyTestPage.razor - after line 600 - there are comments in the code that explain things - it's all for the sake of one event on that component that will set the flags as desired.
  • the _Host.cshtml page contains the JS Interop code (see the comments, consider refactoring or implementing logic more suitable to your needs, perhaps also scoping this so it can work for more than one grid if you need that)
  • the CollapseExpandEventDispatcher class - this is the shortest code I can write to raise a C# event from JS. This one is static and you may want to refactor that so the component with the grid passes a .NET object to the initializatoin of the JS event listener, so that you can encapsulate events properly and raise them only on the necessary components.

 

Regards,
Marin Bratanov
Progress Telerik

 UI for Blazor
Attached Files:
Gary
Posted on: 19 Feb 2020 16:41

I'm including a page with self supporting data.

I disable all buttons in edit mode.  In the end they are left disabled and I'm not sure how I can make this work.  Any advice would be appreciated.

1. Open the form and expand the parent record.

2. Click "Edit" on the child record.  you will see the buttons are all disabled except "Save".

3. Collapse the parent. 

4. Expand the parent.  I am left with all buttons disabled.  The only option is to refresh the page.

Attached Files:
ADMIN
Marin Bratanov
Posted on: 19 Feb 2020 09:23

Hello Gary,

At this point such an event does not exist and I moved your request to the Feedback Portal where you can Follow its implementation: https://feedback.telerik.com/blazor/1454356-event-when-hierarchy-in-the-grid-is-collapsed-or-expanded

Could you provide some more details on the issue you are facing with this setup? I am asking because the built-in editing in the grid should not have issues - when the detail template is closed, the components in it will no longer be rendered and they should not maintain any editable state. If you do persist some state through the grid events (say, OnEdit) and that data "lives" on as it is in the parent model, when the child grid is rendered again it should already use that state without issue.

 

Regards,
Marin Bratanov
Progress Telerik

 UI for Blazor