Numeric TextBox in grid edit template does not binning decimal values if there is no focus in field

In my serverside Blazor app I am trying to make grid with edit temlate.

My app is set to bs-Latn-BA  default culture

            //Startup Configure services
            services.Configure<RequestLocalizationOptions>(options =>
            {
                // define the list of cultures your app will support
                var supportedCultures = new List<CultureInfo>()
                {
                    new CultureInfo("bs-Latn-BA")
                };
                supportedCultures.Add(new CultureInfo("bs-Cyrl-BA"));
                supportedCultures.Add(new CultureInfo("hr-BA"));
                supportedCultures.Add(new CultureInfo("hr-HR"));
                supportedCultures.Add(new CultureInfo("sr-Latn-CS"));
                // set the default culture
                options.DefaultRequestCulture = new RequestCulture("bs-Latn-BA");
                options.SupportedCultures = supportedCultures;
                options.SupportedUICultures = supportedCultures;
                options.RequestCultureProviders = new List<IRequestCultureProvider>() {
                 new QueryStringRequestCultureProvider() // Here, You can also use other localization provider
                };
            });

My problem is handling save data in code behind.
Grid edit template has SfNumericTextBox.
If user save edit record whithout focus in SfNumericTextBox data in save event will be only decimal without decimal reminder.
If user change value of NumericTextBox using spin buttons data in save event will also be floored ,In code behind I get only integer whithout decimal reminder.
If user focus in NumericTextBox and change value data bill be correct with decimal reminder.

In attachment there is razor file with the behavior mentioned.






Attachment: SfNumericTextBox_33d2cb85.7z

1 Reply

VN Vignesh Natarajan Syncfusion Team May 5, 2020 05:45 AM UTC

Hi Admir,  
 
Thanks for contacting Syncfusion support.  
 
Query: “My problem is handling save data in code behind. 
 
We have prepared a sample using your code example and we are able to reproduce the reported issue at our end. We suggest you overcome the reported issue by manually updating the value in OnActionBegin event of the Grid. Refer the below code example  
 
@(TotalFromSaveEvent.HasValue ? TotalFromSaveEvent.Value.ToString("0.00"):"") 
<div class="col-lg-12 control-section"> 
    <div class="content-wrapper"> 
        <div class="row"> 
            <SfGrid DataSource="@GridData" AllowPaging="true" Locale="bs-Latn-BA" Toolbar="@(new string[] { "Edit" ,"Delete","Update","Cancel" })"> 
                <GridEvents OnActionComplete="ActionCompleteHandler" OnActionBegin="BeginHandler" TValue="OrdersDetails"></GridEvents> 
                <GridEditSettings AllowAdding="true" AllowEditing="true" AllowDeleting="true" Mode="@EditMode.Dialog" Dialog="DialogParams"> 
                    <Template> 
                        @{ 
                            var Order = (context as OrdersDetails); 
                        } 
                        <div> 
                            <SfTextBox ID="OrderID" Value="@(Order.OrderID.ToString())" Enabled="@Check" FloatLabelType="FloatLabelType.Always" Placeholder="Order ID"></SfTextBox> 
                            <div class="form-group"> 
                                <label class="col-form-label">Iznis računa (Total)</label> 
  
                                <SfNumericTextBox ID="Total" @ref="NumericBox" Locale="bs-Latn-BA" TValue="double?" Value="@(Order.Total)"></SfNumericTextBox> 
                            </div> 
                        </div> 
                    </Template> 
                </GridEditSettings> 
                <GridColumns> 
                    <GridColumn Field=@nameof(OrdersDetails.OrderID) HeaderText="Order ID" IsPrimaryKey="true" ValidationRules="@(new { required=true, number=true})" TextAlign="@TextAlign.Center" HeaderTextAlign="@TextAlign.Center" Width="140"></GridColumn> 
                    <GridColumn Field=@nameof(OrdersDetails.Total) HeaderText="Order total" ValidationRules="@(new { required=true})" Format="c2" Width="150"></GridColumn> 
  
                </GridColumns> 
            </SfGrid> 
        </div> 
    </div> 
</div> 
@code{ 
    SfNumericTextBox<double?> NumericBox { getset; } 
    public List<OrdersDetails> GridData { getset; } 
    private Boolean Check = false; 
    private object DialogParams = new 
    { 
@@params = new DialogModel { MinHeight = "400px", Width = "450px" } 
    }; 
    protected override void OnInitialized() 
    { 
        GridData = this.GetAllRecords(); 
    } 
  
    double? TotalFromSaveEvent { getset; } = 0; 
  
    public void BeginHandler(ActionEventArgs<OrdersDetails> args) 
    { 
        if (args.RequestType == Syncfusion.Blazor.Grids.Action.Save) 
        { 
            args.Data.Total = NumericBox.Value; 
        } 
    } 
    public void ActionCompleteHandler(ActionEventArgs<OrdersDetails> args) 
    { 
        if (args.RequestType == Syncfusion.Blazor.Grids.Action.Save) 
        { 
            TotalFromSaveEvent = args.Data.Total; 
        } 
    } 
  
. . . .. .  
  
} 
 
 
Refer our UG documentation for your reference 
 
 
Kindly get back to us if you have further queries. 
 
Regards, 
Vignesh Natarajan 


Loader.
Up arrow icon