Limitations on number of rounding places?

2 Answers 3348 Views
Grid
John
Top achievements
Rank 1
John asked on 15 Jan 2016, 04:16 PM

Is there a limit on the number places that a column can be rounded? I am needing some of my columns to round to 4 decimal places. We are experiencing the columns only keeping 2 decimal places even though we have configured the column to have 4 decimal places.

 We were curious if this was a limitation or if we were still doing something wrong in our code or configuration.

 Thanks.

2 Answers, 1 is accepted

Sort by
0
Patrick | Technical Support Engineer, Senior
Telerik team
answered on 15 Jan 2016, 07:05 PM
Hello John,

Take a look at this Telerik Dojo which illustrates how to use numeric formatting.

Here is the code I use to format each column:
columns: [ {
  field: "colOne",
  format: "{0:n1}"  //1 decimal place
}, {
  field: "colTwo",
  format: "{0:n2}"  //2 decimal places
},{
  field: "colThree",
  format: "{0:n3}"  //3 decimal places
},{
  field: "colFour",
  format: "{0:n4}"  //4 decimal places
} ],

If you would like to see more information pertaining to custom formatting, take a look at our documentation.

Hopefully, this helps steer you in the right direction.

Regards,
Patrick
Telerik
 
Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
 
John
Top achievements
Rank 1
commented on 18 Jan 2016, 02:48 PM

Ok, we have our columns configured with those settings. We must have something wrong somewhere in our code. I wanted to be sure that this was not a limitation of the grid.
John
Top achievements
Rank 1
commented on 18 Jan 2016, 02:52 PM

I looked at your example. If add the setting to make the grid editable, when you enter in to the cell to edit only 2 decimal places are shown instead of 4. How do you make all of the decimal places show when editing as well?

http://dojo.telerik.com/UDuGo

0
Patrick | Technical Support Engineer, Senior
Telerik team
answered on 18 Jan 2016, 05:22 PM
Hello John,

In order to show the decimal places while editing, you will need to create a custom Number Editor using a NumericTextBox.  

Take a look at this sample based on the previous dojo illustrating 4 custom editors per column.  

Here is the how I set up the column to show there is a custom editor:
columns: [ {
...{
    field: "colFour",
    format: "{0:n4}",
    editor: numericEditor4
  }...


Here is the function I use to create my editor:
function numericEditor4(container, options) {
  $('<input data-bind="value:' + options.field + '"/>')
   .appendTo(container)
   .kendoNumericTextBox({
    format: "n4",
     decimals: 4
   });
 }


If you would like to see another example, take a look at this sample in our documentation. 

Let me know if you have any questions.

Regards,
Patrick
Telerik
 
Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
 
Tags
Grid
Asked by
John
Top achievements
Rank 1
Answers by
Patrick | Technical Support Engineer, Senior
Telerik team
Share this question
or