I have a repeater template set up to repeat a list of numbers from my table. The numbers have 3 decimal places, but when I try to configure the transform for numeric, the format pattern is greyed out and I get an error on the template because the binding is to a param and it's currently returning 'value' instead of a number.
Is there a workaround for this?
Is this just happening in your designer? I'm assuming in a session, that parameter would be populated, so presumably, it wouldn't error out. If you just want to test it in the designer to make sure the format is correct, just manually type a number into the parameter to check it...
I may be missing something because that sounds too easy. Can you attach a screenshot?
I can't set the transform because the view.params property is a string and not a number, so the Format Pattern is greyed out.
I meant just go to your
Weight view parameter and type in a number, like
1234.56789 to see if the formatting is working correctly. In a session, that param is probably being supplied into the view so it should work there
Also, I just found out that you need to select
Pattern from the first dropdown to get the Format Pattern text field to be editable - when it's set to
Number, it'll be greyed out, regardless if you parameter is a number and if you set it to
Pattern, it should be editable, regardless if your parameter is a number.
You can change from a property binding to an expression binding and format numbers like this:
You mention that the number is coming in as a string (which points to a problem elsewhere) so in that case you could modify the expression to,
There's three ways the param value could be a string even though you're expecting a number:
- The param is received at the page level as part of a URL. URL param values are ALWAYS strings; you'd have to convert it yourself somewhere along the passing chain after it's been received by the page.
- The param value is currently an empty string (or maybe
null). Sorry, but if you default to an empty string, you're declaring the param might be a string and this is reasonable behavior.
- Something within your own logic is setting the type of the param to be a string.
Sorry for the delayed response, I was travelling.
I think the problem is with option 2. I'll try to change the default values to 0.00 instead of null and see what happens. However, I have some columns that have default values that are decimal numbers and still getting an error when trying to transform.
in this case the default value in the table is 48.5 and I still get an error. The datatype in my table is decimal(5,2).
@Transistor : I feel like this is because params show 'value' and aren't populated with real data until the query fires. I mean 'value' as a placeholder. See below.
Just wanted to give an update. I added an expression in the binding and the template is still throwing an error, however, it's working in the project.
I'll consider it solved until there's a fix to how it shows up in the preview and template.
There's nothing to solve; the value you're trying to force a numeric format onto is a string value. To resolve your issue, use a numeric default value instead of a string
I understand what you're saying, but what I don't understand is how to change the param to a number. When I add it to the view, it defaults to 'value'.
value and type
It's the same way you'd set most properties.
It's the simple things sometimes. Thanks for being patient with me.
Yes, looking back at it, you're right. I didn't read it like that. I thought you meant type it in there to troubleshoot, not to set the param datatype. My bad.