Hierarchy Grid - Dialog editing of both parent and child grids

Hi

I have almost got my datagrids working as I need, but just can't seem to get the last part working. If possible, I would like to check that what I'm trying to do can actually be done before spending any more time on it.

Many thanks for your help

Andy

Summary

Hierarchy Grid – I cannot get a dialog edit template to work with both the parent and child datagrids. It works with the parent but not the child.

Notes

I have included a cut down version of my code in index.razor with simulated data. Don’t worry about the appearance and the async database access, it all works fine in my original.

Details

I use the DataGrid as a Hierarchy grid to show parent and child data. This works perfectly.

I have added the facility to edit the parent data in a Template controlled dialog box, also this works perfectly.

When I click save I can capture the updated data in the parent dialog which I then use in a stored procedure to update the database with.  I have shown this here….

 public async Task OnActionComplete(ActionEventArgs<MParent> Args)

{

if (Args.RequestType == Syncfusion.Blazor.Grids.Action.Save)

{

var changedData = Args.Data; // normally has stored procedure access here

}

}

I can expand the child data in the grid. This also works as expected

I now need to edit the child data in another dialog box

If I use a templated dialog box, if fails on 'var SelectedEntry = (context as MChild);' being null

 <Template Context="childDialog">  

        @{

            var SelectedEntry = (context as MChild);

        }

        <div>

            <div class="form-row">

                <div class="form-group col-md-12">

                    <label class="e-float-text e-label-top">Sample child text</label>

                    <SfTextBox ID="Childtext" @bind-Value="@(SelectedEntry.Childtext)" Multiline="true"></SfTextBox>

                </div>

            </div>

        </div>

   

</Template>

 

If I ‘rem’ the above section out and  I don’t use a templated dialog, the standard dialog works but I don't know how to capture the ‘Save’ Event from the standard save button.

Hoped resolution

Confirmation that I can use the parent child hierarchy grid as I described. It would be better if I can use it with the templated dialog box

Even better if you could point me in the way of a similar example.


 

 

 


Attachment: ParentChildIssue_d39f9fc0.zip

3 Replies 1 reply marked as answer

RS Renjith Singh Rajendran Syncfusion Team February 10, 2021 09:28 AM UTC

Hi Andy, 

Greetings from Syncfusion support. 

We suggest to use as like the below codes to overcome the reported problem you are facing. Please refer and use the codes below, 

 
<GridEditSettings AllowEditing="true" Mode="@EditMode.Dialog">  
    <Template Context="childDialog">                                
            @{ 
                var SelectedEntry = (childDialog as MChild); 
            } 
            ... 
    </Template> 
</GridEditSettings> 


And also when performing CRUD actions in Grid, we suggest you to ensure to enable IsPrimaryKey for any one of the unique valued column in Grid. Only based on the primary key value, the CRUD actions will take place in Grid. 

Please get back to us if you need further assistance. 

Regards, 
Renjith Singh Rajendran 


Marked as answer

AJ Andy Jones February 10, 2021 05:12 PM UTC

Hi 

Many thanks for getting back, this looks to have fixed my issue.

Even better, it also fixed an issue where @using BjjPlaylist.UIClasses.PageModels for form validation was causing a conflict of 'context'.

Thanks again

Andy




RS Renjith Singh Rajendran Syncfusion Team February 11, 2021 06:48 AM UTC

Hi Andy, 

We are glad to hear that our suggestion helped you in achieving your requirement. 

Please get back to us if you need further assistance. 

Regards, 
Renjith R 


Loader.
Up arrow icon