Home › Forums › Classic DFFS › Format
- This topic has 11 replies, 3 voices, and was last updated 7 years, 7 months ago by Alexander Bautz.
-
AuthorPosts
-
-
May 8, 2017 at 17:14 #16494
I’m displaying a read only view of a SPFieldNumber field. Is there a way to format with a comma thousands separator and no decimals?
So what I’m looking for is: “2,800” and not “2800.00000000000” (like in my screenshot below). I’ve looked all over the forum and user guide but can’t seem to find how to format a number on a form.
Attachments:
-
May 9, 2017 at 20:42 #16514
Hi,
Which version of DFFS are you using? I believe I have fixed this issue earlier, but cannot find it in the change log – I might have forgot to add it.Alexander
-
May 9, 2017 at 21:52 #16516
I’m using: Dynamic Forms for SharePoint DFFS Backend v4.4.2.9|CSS version: 4.21 / |spjs-utility version: 1.279
-
May 10, 2017 at 15:03 #16524
Hi,
I have a similar issue with a currency field. I guess it’s not taking working with the region settings of the site/SharePoint?
Thanks
Best regards,
Nicole -
May 11, 2017 at 15:17 #16538
So it appears to display a number correctly when an entry exists for the column on form load. But when entering data in the edit or new form, and using a cascading dropdown for instance, it does not display correctly until the data is saved to the list.
-
May 11, 2017 at 21:04 #16541
Hi,
How is it you pull the data into this field? – is it a regular number field that you set to readonly after typing into it? – how are you using it with the cascading dropdown functionality?Alexander
-
May 12, 2017 at 19:30 #16553
1. I am successfully pulling in TargetP1 from a source list using the Cascading dropdown functionality. In the source list I am using a calculated column to convert a number I need to into text (because you don’t allow numbers to be used in the Cascading dropdown functionality). 2. Then I am attempting to convert the text to a number using a rule. This is where I can’t seem to find a way to display it with a thousands separator and no decimals in the New or Edit form. It displays properly in the view form (see the screenshot in my first post).
- This reply was modified 7 years, 7 months ago by Todd Ingersoll.
Attachments:
-
-
May 15, 2017 at 22:58 #16586
I don’t have a built in function in DFFS, but I have one in the vLookup script you can use like this:
spjs.vLookup.formatNumber("10000000",{"decimals":2,"decimalSeparator":".","thousandsSeparator":" "});
This can be used by adding a function in the custom js like this:
function convertStringToNumber(){ var val = getFieldValue("TargetP1"), fVal = ""; fVal = spjs.vLookup.formatNumber(val,{"decimals":2,"decimalSeparator":".","thousandsSeparator":" "}); setFieldVal("Target",fVal); }
Remove the “Set field value” section from the rule, and call the custom function instead.
Let me know how this works out.
Alexander
-
May 16, 2017 at 15:46 #16595
Thanks Alexander.
Is setFieldVal coming from somewhere else? I’m getting this error:- This reply was modified 7 years, 7 months ago by Todd Ingersoll.
Attachments:
-
May 16, 2017 at 16:08 #16599
I got the error to go away as I noticed you referred to that function as setFieldValue (with a “ue”) in another post here. I cannot get it to display or set that field, however.
- This reply was modified 7 years, 7 months ago by Todd Ingersoll.
-
-
May 25, 2017 at 12:20 #16676
This is now working. Here’s what I have for Custom JS and I call when the Cascading Dropdown is chosen:
} function convertStringToNumber(){ var val = getFieldValue("TargetP1"), fVal = ""; fVal = spjs.vLookup.formatNumber(val,{"decimals":0,"decimalSeparator":".","thousandsSeparator":","}); setFieldValue("TargetNumP1",fVal); }
-
May 25, 2017 at 13:43 #16680
Sorry for the delay – I must have missed your reply.
I’m glad you figured it out – and yes, it should have been “setFieldValue” and not “setFieldVal”.
This function is part of spjs-utility.js.
Best regards,
Alexander
-
-
AuthorPosts
- You must be logged in to reply to this topic.