What is the better solution to format/restrict *-input entry in Polymer 1.0 - dart-polymer

I would like to know if exists best practices to format and restrict on *-input elements entry in Polymer 1.0.
For example:
Number/Currency = '999.999.999,99'
Date = 'dd/mm/yyyy'
Is there a pattern default to guarantee that entry just number, comma and points?
Is there some form to format the display, similar to expressions filter in OLD-Polymer?

iron-input supports an allowed-pattern attribute https://elements.polymer-project.org/elements/iron-input

Related

Formatting calculated values in Adobe Document Generation API

In the template language docs for Adobe Document Generation, mathematical expressions can be done using tags like below...
{{expr(revenue - expenditure)}}
This works and outputs a number, but is there any way to apply formatting to the number, for example, $50,000.00 where the calculated value is just 50000?
Remember that doc gen uses JSONata (https://docs.jsonata.org/overview.html) for it's template parsing. As I've learned and played with docgen, the JSONata docs have been really helpful. For this particular example, there's a function built in documented under Numeric functions - $formatNumber. At minimum it takes a number input and a mask. So to format it as you would want, use:
{{$formatNumber(revenue-expenditure, '#,###.00')}}
Notice that you don't use expr above, just the function.

User input money value in grails

I need to get a money value from the user, but the user can type the number in different formats:
1.234.234,78
1234566,26
123,123,132.12
I don't know how to treat the variable.
I have to transform that value in Double type but if the user give me a value with "," the program generate an exception, how can I handle this?
If you want to handle money then I recommend you a great grails plugin with many feature for currencies handling and conversions etc.
Have a look at Currency plugin.
In your domain static constraints use matches with the regular expression that handles currency format.
Then using java.text.NumberFormat allows you to format double regardless of having comma in the input.

How to specify a range of data when using HighCharts with <table>?

I found this great tutorial on using HighCharts with , very useful but I couldn't find a related API letting me only specify a part of data in the table.
For example, in the case above (I added 2 cols to make it more easy to describe), what should I do if I only want to use HighCharts to display the data in a range (in the red dotted range)
Is there some parameter like datarange:{[0,0,4,4]} or even sometimes I only want to take care of some more complicated ranges (in the second image)
According to documentation:
* table : String|HTMLElement
* A HTML table or the id of such to be parsed as input data. Related options ara startRow,
* endRow, startColumn and endColumn to delimit what part of the table is used.
You can use startColumn/endColumn but data range is unforutnaltey not supported. You can request your suggestion in userVoice http://highcharts.uservoice.com/ system
http://jsfiddle.net/FYtnj/1/
Short description of how data module works you can find in full version of that file.
As you can see you can setup startColumn/startRow and endColumn/endRow. Something like data range isn't supported.
There is columns/rows option, but it works in a different way: http://jsfiddle.net/Y53FZ/

Grails overriding locale number format

I have a Grails application and I want to save a number with decimal places, e.g. 902.11. In my app, I use Czech locale, so the decimal point is represented as comma "," instead of point ".". But in the browser I want to do some calculations by Javascript, so the decimal point must be represented by ".".
Is there a solution so I can customize the Czech locale in my application so it will use the "." instead of ","? Or is there any other solution to this problem?
You should use the formatNumber tag and specify a locale that uses dots for decimal places, e.g.
<script ...>
var someNumber = <g:formatNumber number="${myNumber}" locale="en" />;
// ... do some javascript calculations
</script>
For reference:
formatNumber will work when you write the value out into the page, but Lojza probably wanted to get the number back to the controller which is not straightforward since the Grails data-binder is locale specific, so it will expect the number to be formatted according to the Czech locale instead of the base JS format.
You can either override the binder value converter which will be global for your application (may not what you want), or use a command object and retrieve the number value into a String attribute of the command object, so that Grails will not try to apply any number parsing on it. Then you manually convert this string into number according to the base JS format.

Negative decimals in (parentheses) not binding

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.

Resources