Is it possible to update a Numeric Textbox based on another numeric textbox's value?

Greetings!

I'm trying to sum the value of two fields and display the result on a third field:



The code should sum the values, insert the result in the totalPrice variable and display it on Console.

After that, the StateHasChanged( ) should render the dialog again and the third field should display the result.



The code works, the value is displayed but the third field doesn't show it.

Is it possible to render the modal again and show the value?

I'm sending the code for further informations.

I'd appreciate your help,


Thank you


Attachment: CadastroPedido_7661c564.rar

6 Replies 1 reply marked as answer

SN Sevvandhi Nagulan Syncfusion Team June 23, 2021 11:57 AM UTC

Hi Consensu, 


Greetings from Syncfusion support. 


Currently we are validating the reported issue and will update further details on 25th of June 2021. We appreciate your patience until then. 


Regards, 
Sevvandhi N 



PM Ponmani Murugaiyan Syncfusion Team June 27, 2021 10:04 AM UTC

Hi Consensu,  

Thanks for your patience. 

To overcome the reported issue, we suggest you by disabling the PreventRender inside the OnActionComplete event of Grid component. Please refer and add the below codes in your application. 


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

Please get back to us if you need further assistance. 

Regards, 
Ponmani M 



ED Eduardo June 28, 2021 02:12 PM UTC

Hello, again! Thank you for you answer.


I'm using the Dialog edit mode, because editing directly on the grid is not a good option for me. 

Is is possible to update the values of the SfNumericTextBox inside the Dialog?



VN Vignesh Natarajan Syncfusion Team June 29, 2021 06:09 AM UTC

Hi Consensu,  
 
Thanks for the update.  
 
Query: “Is is possible to update the values of the SfNumericTextBox inside the Dialog? 
 
We have analyzed your query and we would like to inform you that for some performance reasons we have prevented the rendering of components during the external actions. Hence the value is not updated when updated using ValueChange event. We suggest you to overcome the reported query by calling a PreventRender method of Grid with false argument in the ValueChange event of NumericTextbox component not in OnActionComplete event.  
 
Refer the below code example  
 
<SfGrid @ref="Grid" DataSource="@GridData" Toolbar="@(new string[] {"Add""Edit" ,"Delete","Update","Cancel" })"> 
    <GridEditSettings AllowAdding="true" AllowEditing="true" AllowDeleting="true" Mode="@EditMode.Dialog"> 
        <Template> 
            @{ 
                var Order = (context as OrdersDetails); 
            } 
            <div> 
                <div class="form-row"> 
                    <div class="form-group col-md-6"> 
                        <SfNumericTextBox ID="OrderID" @bind-Value="@(Order.OrderID)" Enabled="@Check" FloatLabelType="FloatLabelType.Always" Placeholder="Order ID"></SfNumericTextBox> 
                    </div> 
                    <div class="form-group col-md-6"> 
                        <SfAutoComplete TItem="OrdersDetails" ID="CustomerID" @bind-Value="@(Order.CustomerID)" TValue="string" DataSource="@GridData" FloatLabelType="FloatLabelType.Always" Placeholder="Customer Name"> 
                            <AutoCompleteFieldSettings Value="CustomerID"></AutoCompleteFieldSettings> 
                        </SfAutoComplete> 
                    </div> 
                </div> 
                <div class="form-row"> 
                    <div class="form-group col-md-6"> 
                        <SfNumericTextBox ID="Price" @bind-Value="@(Order.Price)" TValue="double?" FloatLabelType="FloatLabelType.Always" Placeholder="Price"></SfNumericTextBox> 
                    </div> 
                    <div class="form-group col-md-6"> 
                        <SfNumericTextBox ID="Qty" @bind-Value="@(Order.Qty)" ShowSpinButton="false" TValue="double?" FloatLabelType="FloatLabelType.Always" Placeholder="Quantity"> 
                            <NumericTextBoxEvents ValueChange="@((args)=>OnChange(args,Order))" TValue="double?"></NumericTextBoxEvents> 
                        </SfNumericTextBox> 
                    </div> 
                    <div class="form-group col-md-6"> 
                        <SfNumericTextBox ID="Total" @bind-Value="@(Order.Total)" ShowSpinButton="false" TValue="double?" FloatLabelType="FloatLabelType.Always" Placeholder="Total Amount"></SfNumericTextBox> 
                    </div> 
. . . . .  
            </div> 
        </Template> 
    </GridEditSettings>     
</SfGrid> 
  
@code{ 
  
    SfGrid<OrdersDetails> Grid { getset; } 
  
    private Boolean Check = false; 
  
    public void OnChange(Syncfusion.Blazor.Inputs.ChangeEventArgs<double?> Args, OrdersDetails order) 
    { 
        order.Total = order.Price * Args.Value; 
        Grid.PreventRender(false); 
    } 
 
 
Note: TotalValue gets updated only after Quantity textbox is focused out.  
 
Kindly refer the below sample for your reference 
 
 
Please get back to us if you have further queries.  
 
Regards, 
Vignesh Natarajan.  


Marked as answer

PA Paolo December 17, 2022 02:40 PM UTC

Hi support,

thank you! I confirm that your last solution is perfect. I had a similar scenario, and I implemented your solution without any problems.

Regards

Paolo



SG Suganya Gopinath Syncfusion Team December 19, 2022 12:43 PM UTC

Hi Paolo,

We are glad that the provided solution helped to solve the issue. Please get back to us for further assistance. 

Regards,

Suganya Gopinath.


Loader.
Up arrow icon