Hide Part of the Edit Dialog Based on Change of Value in Field

I am trying to hide or show a div in the grid edit dialog by a change in the checked status of an SfCheckBox. This is to allow the user to enter additional data if the checkbox is checked. The div does not change hidden status until I click Save at which time the dialog closes.

<div class="form-group col-md-3">
        <label class="e-float-text e-label-top">Uses Belts</label>
        <SfCheckBox ID="UsesBelts" @bind-Checked="@rank.UsesBelts" @onchange="OnUsesBeltsChange"/>
 </div>

<div hidden="@showBeltAttributes"> <!-- Belt configuration section -->

    <div class="form-row">
        <div class="form-group col-md-3">
            <label class="e-float-text e-label-top">Belt</label>
            <div><BECanvas Width="70" Height="70" @ref="_canvasReference"/></div>
        </div>
    </div>
...
private void OnUsesBeltsChange()
{
    showBeltAttributes = !showBeltAttributes;
    StateHasChanged();
}


Thank you


3 Replies

RS Renjith Singh Rajendran Syncfusion Team June 13, 2022 02:43 PM UTC

Hi Judi,


Greetings from Syncfusion support.


Based on this scenario, we suggest you to set PreventRender as false in the OnActionComplete event handler based on RequestType as Add/BeginEdit to achieve this requirement. Please refer and add the codes below.


 

<GridEvents OnActionComplete="OnActionComplete" ... TValue="Orders"></GridEvents>

 

public void OnActionComplete(ActionEventArgs<Orders> args)
{
    if (args.RequestType.Equals(Action.Add) || args.RequestType.Equals(Action.BeginEdit))
    {
        //based on Add or Edit action disable the PreventRender
        args.PreventRender = false;
    }
}

 


Reference :

https://blazor.syncfusion.com/documentation/datagrid/dialog-editing#implement-calculated-column-inside-grid-dialog-editing

https://blazor.syncfusion.com/documentation/datagrid/editing#use-different-editmode-for-addedit-action


Please check this from your side and get back to us if you need further assistance.


Regards,

Renjith R



JS Judi Smith June 15, 2022 09:02 PM UTC

That is super handy! Thank you so much!



SS Swetha Srikumar Syncfusion Team June 16, 2022 11:25 AM UTC


Most welcome, please get back to us if you need any other assistance. 


Loader.
Up arrow icon