Grid column edit formatting/validation

I need to format some data and validate in some columns for my grid.  I will have a few columns that have checkboxes, numeric with 2 decimals and dates etc.

Is there a way when data is pulled in from a query such as 1234.10000000000 to limit automatically to 2 decimal places?

Also I looked up an example you can see in my attached video/code.. but when i go to try to input a value it just gets greyed out.. i can't even put anything in there and its editable.  Maybe theres some option i need to put or something i'm missing.  As soon as I take out EditType="EditType.NumericEdit", then it works.. but then the validation doesn't work and displaying 2 decimals. I just need it to limit to two decimal places for display and then when editing only allow numbers with 2 decimal places.  I'll also want a checkbox for the input type and datetime. thanks i'm on version 18.4.0.42

i was trying to use this..
    public IEditorSettings PriceEditParams = new NumericEditCellParams
    {
        Params = new NumericTextBoxModel() { Min = 0, ShowSpinButton = false, Decimals = 2, Format = "n2" ,ValidateDecimalOnType = true }
    };

i tried to post in the direct incident forums but i keep getting an error

Attachment: GridEditValidation_d8fd484c.zip

1 Reply 1 reply marked as answer

RN Rahul Narayanasamy Syncfusion Team February 20, 2021 03:54 AM UTC

Hi Chris, 

Greetings from Syncfusion. 

We have validated your query with the provided information and checked the reported problem. We could not reproduce the reported problem at our end. Here, we have rendered numeric column(Freight) based on your numeric column. Find the below code snippets and sample for your reference. 

 
<SfGrid DataSource="@Orders" AllowPaging="true" Toolbar="@(new List<string>() { "Add", "Edit", "Delete", "Cancel", "Update" })" Height="315"> 
    <GridEditSettings AllowAdding="true" AllowEditing="true" AllowDeleting="true" Mode="EditMode.Normal"></GridEditSettings> 
    <GridColumns> 
        <GridColumn Field=@nameof(Order.OrderID) HeaderText="Order ID" IsPrimaryKey="true" ValidationRules="@(new ValidationRules{ Required=true})" TextAlign="TextAlign.Right" Width="120"></GridColumn> 
        <GridColumn Field=@nameof(Order.CustomerID) HeaderText="Customer Name" ValidationRules="@(new ValidationRules{ Required=true})" Width="120"></GridColumn> 
        <GridColumn Field=@nameof(Order.OrderDate) HeaderText=" Order Date" EditType="EditType.DatePickerEdit" Format="d" TextAlign="TextAlign.Right" Width="130" Type="ColumnType.Date"></GridColumn> 
        <GridColumn Field=@nameof(Order.Freight) HeaderText="Freight" Format="n2" EditorSettings="@PriceEditParams" TextAlign="TextAlign.Right" EditType="EditType.NumericEdit" Width="120"></GridColumn> 
        <GridColumn Field=@nameof(Order.ShipCountry) HeaderText="Ship Country" EditType="EditType.DropDownEdit" Width="150"></GridColumn> 
    </GridColumns> 
</SfGrid> 
 
@code{ 
    public List<Order> Orders { get; set; } 
 
    public IEditorSettings PriceEditParams = new NumericEditCellParams 
    { 
        Params = new NumericTextBoxModel<object>() { Min = 0, ShowSpinButton = false, Decimals = 2, Format = "n2", ValidateDecimalOnType = true } 
    }; 
 
    . . . 
} 



If you are still facing the problem, then could you please share the below details. It will be helpful to validate and provide a better solution. 

  • Reproduce the problem in the provided sample and revert back to us.
  • Share a simple reproduceable sample if possible.

Regards, 
Rahul 


Marked as answer
Loader.
Up arrow icon