how can I apply format 0:c to a grid footer template

7 posts, 0 answers
  1. Evgeny Vdovin
    Evgeny Vdovin avatar
    29 posts
    Member since:
    May 2006

    Posted 20 Apr 2012 Link to this post

    HI 

    How can I apply format 0:c to a footertemplate in the Grid.
    In one of your example you have avg like this Average: 10.12987012987013 and I think it will be better to present like Average: 10.13

    Regards,
    Evgeny Vdovin
      
  2. Gergo
    Gergo avatar
    20 posts
    Member since:
    Mar 2012

    Posted 20 Apr 2012 Link to this post

    Hi Evgeny,

    You can use the kendo.toString() method to format the footerTemplate,
    Please see this example below:

    $("#grid").kendoGrid({
               dataSource: {
                   data: [
                       {
                           OrderId: 1,
                           NrOfProducts: 2,
                           Price: 155.9987
                       },
                       {
                           OrderId: 2,
                           NrOfProducts: 12,
                           Price: 987.44587
                       },
                       {
                           OrderId: 3,
                           NrOfProducts: 22,
                           Price: 0.7878
                       }
                       ],
     
                   aggregate: [
                   { field: "NrOfProducts", aggregate: "sum" },
                   { field: "Price", aggregate: "sum"}]
               },
               sortable: true,
               scrollable: false,
               columns: [{
                   field: "OrderId",
                   title: "ID of the Order"
               },
               {     field: "NrOfProducts",
                   title: "Number Of Products",
                   footerTemplate: "Total Products : #= kendo.toString(sum, '0.00') #"
               },
               {    field: "Price",
                   title: "Price",
                   footerTemplate: "Total Price: #= kendo.toString(sum, 'C') #"
                }]
           });


    Kind Regards,
    Gergő
  3. Kendo UI is VS 2017 Ready
  4. Evgeny Vdovin
    Evgeny Vdovin avatar
    29 posts
    Member since:
    May 2006

    Posted 20 Apr 2012 Link to this post

    Thanks a lot

    Regards,
    Evgeny Vdovin
  5. Dr.YSG
    Dr.YSG avatar
    210 posts
    Member since:
    Dec 2009

    Posted 18 Jun 2013 Link to this post

    And if I want to do that for this bit of HTML (I am running out of quote options)?

    01.data-columns='[
    02.    "Class",
    03.    "Type",
    04.     {field: "FileCount",
    05.     format: "{0:n2} MB",
    06.     aggregates: ["sum"],
    07.     footerTemplate: "Total: #=data.FileCount? data.FileCount.sum : 0 #"
    08.    },
    09.    {field: "Size",
    10.     format: "{0:n2} MB",
    11.     aggregates: ["sum"],
    12.     footerTemplate: "Total: #=data.Size?data.Size.sum : 0 # MB"
    13.    },
    14.    {field: "Date",
    15.     format: "{0:F}" },
    16.    "Path",
    17.    {command: "destroy"},
    18.]'>
  6. Alexander Valchev
    Admin
    Alexander Valchev avatar
    2877 posts

    Posted 21 Jun 2013 Link to this post

    Hello Dr.YSG,

    You can use backslash to escape quotation marks:
    "Total: #= kendo.toString(data.FileCount ? data.FileCount.sum : 0, \"n2\") # MB"


    Regards,
    Alexander Valchev
    Telerik
    Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
  7. Philip
    Philip avatar
    1 posts
    Member since:
    Aug 2012

    Posted 19 Jun 2014 Link to this post

    I'm using KendoUI 2014.1.528

    I'm trying to format a footer as well using this:

    footerTemplate: "#= kendo.tostring(average, \"n2\") #"

    I get "JavaScript runtime error: Object doesn't support property or method 'tostring'"

    Am I doing something wrong?
  8. Reqs
    Reqs avatar
    9 posts
    Member since:
    Dec 2013

    Posted 19 Jun 2014 in reply to Philip Link to this post

    bsimms, try toString instead of tostring?
Back to Top
Kendo UI is VS 2017 Ready