We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. Image for the cookie policy date
close icon

Restrict decimals for child grid

Good afternoon,

I'm trying to restrict the decimals of the numeric field "orden" in child grid. Currently, I have the field "Orden" in the parent grid and it doesnt have decimal positions which is correct. But I want to do so in the child grid for its own "Orden" field but I dont know how.

Probably it is very similar with the instructions: ValidateDecimalOnType = true, Decimals = 0, Format = "N"...... but I don´t know exactly how.

Can you please help me??

In advance, thanks!!




////////////////////////MY CODE////////////////////////

@{
    ViewData["Title"] = "Catálogo de coberturas póliza hogar";
    Layout = "~/Areas/Sistema/Views/Shared/_Layout.cshtml";
}

<h2>Catálogo de coberturas póliza hogar</h2>


@{
    var dataManager2 = new Syncfusion.EJ2.DataManager()
    {

        Adaptor = "UrlAdaptor",
        Url = "/Sistema/Catalogos/coberturasCategoriasHogarGrid_Read/ ",
        CrudUrl = "/Sistema/Catalogos/coberturasCategoriasHogarGrid_CRUD/ ",
        RequestType = "Post",
        CrossDomain = true
    };

    var childGrid = new Syncfusion.EJ2.Grids.Grid()
    {
        DataSource = dataManager2,
        QueryString = "categoriaID",
        Toolbar = new List<string>() { "Cancel", "Update", "Add", "Delete" },
        EditSettings = new Syncfusion.EJ2.Grids.GridEditSettings()
        {
            AllowAdding = true,
            AllowEditing = true,
            AllowDeleting = true
        },
        Columns = new List<Syncfusion.EJ2.Grids.GridColumn>
        {
            new Syncfusion.EJ2.Grids.GridColumn(){ Field = "coberturaID", HeaderText = "coberturaID", Visible = false, Id = "categoriaID", IsPrimaryKey = true },
            new Syncfusion.EJ2.Grids.GridColumn(){ Field = "categoriaID", HeaderText = "categoriaID", Visible = false, Id = "categoriaID" },
            new Syncfusion.EJ2.Grids.GridColumn(){ Field = "nombreCobertura", HeaderText = "Nombre Cobertura"},
            new Syncfusion.EJ2.Grids.GridColumn(){ Field = "orden", HeaderText = "orden"}
        },
        ActionBegin = "actionBegin"
    };

}

@*childGrid="childGrid"*@

<ejs-grid id="coberturasHogarGrid" childGrid="childGrid" toolbar="@(new List<string>() { "Cancel", "Update", "Add", "Delete" })">
    <e-data-manager id="dataManager" adaptor="UrlAdaptor" url="/Sistema/Catalogos/coberturasHogarGrid_Read" crudUrl="/Sistema/Catalogos/coberturasHogarGrid_CRUD" requestType="Post"></e-data-manager>
    <e-grid-editSettings allowDeleting="true" allowEditing="true" allowAdding="true" mode="Normal" showDeleteConfirmDialog="true"></e-grid-editSettings>
    <e-grid-columns>
        <e-grid-column field="categoriaID" isPrimaryKey="true" isIdentity="true" visible="false"></e-grid-column>
        <e-grid-column field="nombreCategoria" headerText="Nombre de la categoría" visible="true"></e-grid-column>
        <e-grid-column field="orden" headerText="Orden" visible="true" editType="numericedit" format="N" edit="@(new { @params = new Syncfusion.EJ2.Inputs.NumericTextBox() {
            ValidateDecimalOnType = true,
            Decimals = 0,
            Format = "N"
           }
   })" ></e-grid-column>
    </e-grid-columns>
</ejs-grid>

<script>
    function actionBegin(args) {
        if (args.requestType === "save") {
            this.query.params = [];
            this.query.addParams('categoriaID', this.parentDetails.parentRowData.categoriaID);
        }
    }
</script>

3 Replies

HJ Hariharan J V Syncfusion Team July 25, 2019 07:19 AM UTC

Hi Javier, 

Greetings from the Syncfusion support, 

We have validated your query provided the information and we created a sample with numeric editing in decimal of zero using edit params in the Child Grid. We have already discussed about the edit params in Help Documentation. Please refer the below code example, sample and Help Documentation for more information. 

[index.cshtml] 

var editParams = new { @params = new { format="N", decimals=0} }; 
    .   .    .   . 
       Columns = new List<Syncfusion.EJ2.Grids.GridColumn> 
        { 
        new Syncfusion.EJ2.Grids.GridColumn(){ Field = "OrderID", HeaderText = "OrderID", Visible = false, Id = "categoriaID", IsPrimaryKey = true }, 
        new Syncfusion.EJ2.Grids.GridColumn(){ Field = "ShipCity", HeaderText = "Ship City", Visible = false, Id = "categoriaID" }, 
        new Syncfusion.EJ2.Grids.GridColumn(){ Field = "ShipName", HeaderText = "Ship Name"}, 
        new Syncfusion.EJ2.Grids.GridColumn(){ Field = "Freight", HeaderText = "Freight", Format="N", EditType="numericedit", Edit= editParams } 
        } 
    }; 
 
        } 
        <div class="container"> 
            <ejs-grid id="Grid" allowPaging=true childGrid="childGrid"> 
                <e-grid-pagesettings pageSize="4"> </e-grid-pagesettings> 
                <e-data-manager url='http://js.syncfusion.com/demos/ejservices//Wcf/Northwind.svc/Employees/' adaptor="ODataAdaptor" crossdomain="true"></e-data-manager> 
                .   .   .   . 
           </ejs-grid> 
        </div> 



Please get back to us, if you need further assistance. 

Regards, 
Hariharan 



JA Javier A Aguilera July 25, 2019 07:15 PM UTC

Thank you for your fast answer, it worked perfectly!


HJ Hariharan J V Syncfusion Team July 26, 2019 06:54 AM UTC

Hi Javier,

Thanks for your update.

We are happy to hear that your issue has been resolved.

Regards,
Hariharan

Loader.
Live Chat Icon For mobile
Up arrow icon