Hierarchical grids - using date as child grid parameter

2 posts, 0 answers
  1. Matias
    Matias  avatar
    21 posts
    Member since:
    Mar 2016

    Posted 20 Apr Link to this post

    I have 2 grids that work correcly, but one of the parameters used to get the data of the child grid is a date with a format that varies when using different web browsers.

    When the controller action recieves the date, the string has different values according to the browser used. For example:

    -IE: "Mon Oct 17 00:00:00 UTC-0300 2016"
    -Chrome: "Mon Oct 17 2016 00:00:00 GMT-0300 (Hora estándar de Argentina)"
    -Firefox: "Mon Oct 17 2016 00:00:00 GMT-0300"

    I'd like to know if I can format the date before sending it to the controller.

    This are my grids:

            .DataSource(dataSource => dataSource
                .Read(read => read.Action("Read", "controller")
            .Columns(columns =>
                columns.Bound(foo => foo.fecha_venc).Title(Global.Fecha).Format("{0:dd/MM/yyyy}"); //This is the date I need formatted
                columns.Bound(foo => foo.espe_codigo).Title(Global.Especie);
                columns.Bound(foo => foo.clas_codigo).Title(Global.Clase);


            .DataSource(dataSource => dataSource
                .Read(read => read.Action("childGrid_Read", "controller", new { fecha = "#=fecha_venc#", especie = "#=espe_codigo#", cliente = @ViewBag.cliente, clase = "#=clas_codigo#" }))
            .Columns(columns =>
                columns.Bound(o => o.oper_numero).Title(Global.NumeroOperacion)
                .ClientTemplate("<a href='\\\\\\#' onclick=\"showDetails('\\#=oper_numero\\#')\">\\#=oper_numero\\#</a>");
                columns.Bound(o => o.oper_forigen).Title(Global.FechaOrigen).Format("{0:dd/MM/yyyy}");
                columns.Bound(o => o.espe_codigo).Title(Global.Especie);
                columns.Bound(o => o.clas_codigo).Title(Global.Clase);



    public ActionResult childGrid_Read([DataSourceRequest]DataSourceRequest request, string fecha, string especie, string cliente, string clase)
                //the string fecha comes with the wrong formatting, and I need it to come as dd/MM/yyyy


    Thank you very much

  2. Maria Ilieva
    Maria Ilieva avatar
    4017 posts

    Posted 25 Apr Link to this post

    Hello Matias ,

    Since the dates are created on the client when the response from the server is returned - the dates are always created with an offset according to the timezone of the browser:
    You can try to create date in the browser's console and see the result (you will see the difference if your timezone is different than the UTC 0):
    new Date("2012-01-12T18:45"); 

    Thus said, I suggest you to take a look at this code library:


    Maria Ilieva
    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Feedback Portal and vote to affect the priority of the items
  3. UI for ASP.NET AJAX banner
Back to Top