using mvc kendo grid to represent the dat
I have decimal values likes
Actual O/P
61.05
16.00
15.92
Expected O/P This is What i am looking for
61.05
16
15.92
I used to display the value like this
Format("{0:n2}")
How can I achieve expected o/p, with the help of kendo format
Strange, that should actually work.
You can try the following formatting string as an alternative solution: {0:0.00}.
Format("{0:n2}") will force all input numbers to 2 decimal places. If you want to apply decimal places based on the value, use Format("0:0.##}") (where the number of decimal places (#) is the maximum number of decimal places you will have).
If you don't need the column to be numbers (for example for sorting, filtering or summing in the grid), then pass string values to the column and do the unusual formatting requirement in the controller.
Related
Something strange is happening with the sorting. I am sorting G (weight) from smallest to largest. The numbers are 1 to 41.
It doesn't sort starting from the number 1. Instead the order is 10,11,12,13,14,15,16,17,18,19,2,20,21,23,25,26,3,30,35,4,41,5,6,7,8,9.
I know technically 10 starts with the number one, but shouldn't this application be smart enough to know that you don't start counting at number 10? The smallest weight of 2 should be first, followed 3,4,5,67,8,9,10,11,12,etc.
Is this not possible with that sorting option?
try to multiply your G column with 1 to convert your string numbers into numeric numbers as of, you are sorting it now by alphabetical order 10,1,20,2 not numerical 1,2,10,20
It sounds like your Col-G weights are strings and not actual numbers. And assuming that is the case, Google sorts in order according to ASCII char numbers. If you have any non-numeric characters appended (e.g., "kg"), then you've created strings automatically. However, if you only have digits and they somehow got into your sheet as strings (which are not actively generated by formula), you can try selecting that column and choosing Format > Number > 0.
I have a sheet with values that I want to format in grams. The values range from high to low and I wish to format them with a comma as a thousand-separator, and rounded to two decimal places, but trimming both the decimal point and places where the number is a whole number. The following examples should explain better:
1000 to be presented as 1,000g
0.75 to be presented as 0.75g
0.2 to be presented as 0.2g
0.1234 to be presented as 0.12g
I've tried using a custom number format of #,##0.##g but this does not satisfy my first requirement (a) where the numbers are whole numbers and leaves an insignificant decimal point (i.e. 1,000.g), although does very well at formatting the remaining three requirements (b, c and d).
Is there a way of overcoming this?
#,##0.00_ g;(#,##0.00 g)
I'm a bit late to this article but I found the above format works for me.
Assuming your numbers are in column A with a header. You could try putting this in B2 then hide column A:
=arrayformula(if(arrayformula(TRUNC(A2:A,2)&"g")="0g","",arrayformula(TRUNC(A2:A,2)&"g")))
The best I could do with format was [=0]0;.## It gets rid of the period in 1000 but does not truncate 0.1234 and doesn't add the g. Maybe you could work with that if you must use format. I really don't think format can do it.
I have a report that calculates the % of Revenue versus the total Contract Value for a job. In SSRS I have it set to a percentage with 2 decimal points. The format property is set to %0.00. Now when I export to excel it looks great in all cases but one. If the Revenue Amount is $0.00 and its divided by a Contract Value greater then $1 then the value is set to 0.0000000000000000 in Excel and not the 0.00% I expect.
How can I make it so it displays the expected 0.00%?
When creating Reporting Services (SSRS) reports, I have used FormatCurrency() and FormatPercent() around values to make the report look good. I learned that when you use those values, and export to Excel, you end up losing the ability to sum the values and what's on your SSRS report is much different on your Excel worksheet. This is because everything is exported as text.
How to solve this. Remove all the FormatCurrency() and FormatPercent() functions.
On each of your fields, highlight them, then in the properties area, there is a “Format” property. I set that to C2 (C for Currency, 2 for the number of digits after the decimal, so if you wanted zero, it would be C0). Again for Percentages, same thing, highlight all the fields, and set “Format” to P2 (P for Percentage, 2 for the number of digits after the decimal).
Have you tried using P2 in the format property?
The Standard Numeric Formats tend to render better in Excel.
UPDATE:
I have recently had an issue where I was using P1 for the format but the export would be 2 decimal places unless it rounded to 1.
The fix was to use 0.0% for the format property instead of P1. Now all of the cells have the same formatting - even the zeroes.
I tried the suggested answer and it works great for currency. I wanted just plain decimals and ended up going with " #,0;(#,0);'' ". The final parameter makes zero values invisible. Of course, there are a ton of these formats.
Text Box Properties
I got this by using the Number tab on the Text Box Properties dialogue box (right-click the text box and select Text Box Properties). Once I set it, I could return to the Properties window for the text box and see how that action got translated. Then I applied it to all the text boxes in the tablix.
Hope this helps.
TextBox Properties Dialogue Box
I have stringgrid on delphi form and i am trying to divide values of one cell with value of another cell in another column.
But the problem is, stringgrid cells are populated with different types of numbers, so I am getting ConvertErrors.
For example the numbers in cells can look like
0.37 or 34 or 0.0013 or 0.00 or 0.35 or 30.65 or 45.9108 or 0.0307 or 6854.93.
In another words I never know is it going to be real, float, integer or any other kind of type in those cells.
I have looked everywhere on internet but no luck. Anyone any ideas. By the way I am not exactly Delphi expert. Thanks.
For each string, convert it first to a float value using StrToFloat function in SysUtils.pas . This should allow for any numerical type to be dealt with (unless you have something unusual like complex numbers). As you have some zero values in your list above you should also ensure that you check for divide by zero conditions as this will also potentially throw an exception.
SysUtils has many functions such as TryStrToFloat, TryStrToInt, TryStrToInt64 etc for this purpose. These functions accept a reference parameter (var parameter) for returning the converted value and function itself returns true if the conversion is successful.
If you are sure that the string has a valid number then you can check the input string to see if it has a decimal point before deciding which function to use.
Treat all the numbers as float. Use StrToFloat, divide the numbers, and then convert the result back to string with FloatToStr. If the result is an integer, no decimal point would be produced.
I'm using String.Format("{0:####.00;(####.00);0.00}", Model) to display a negative currency of -1600.00 as (1600.00). However, decimal inputs in this format cannot be parsed by the model binder.
I suspect I need to change a culture setting, but I don't know where.
How do I tell my ASP.NET MVC 3 application that a decimal form input value of (1600.00) means -1600.00?
Solved. See answer below.
Solved by keeping my display templates' formatting and changing my editor templates to use a standard minus without parentheses.