Format decimal in a List

Confluence User - 14 Oct, 2018

Halo,

I'd like to make my column in a format of 2 decimal.

Tried this script but blank, in General > Action Mapping > Formatter > Configure Bean Shell Formatter

import java.text.DecimalFormat;
import org.joget.apps.app.service.AppUtil;
import org.joget.apps.form.model.Element;
import org.joget.apps.form.model.FormData;
import org.joget.apps.form.model.FormRow;
import org.joget.apps.form.model.FormRowSet;
import org.joget.apps.form.model.FormStoreBinder;
import org.joget.plugin.base.PluginManager;

public FormRowSet store(Element element, FormRowSet rows, FormData formData) {

//format to 2 decimal
DecimalFormat df = new DecimalFormat("#.00");
row.setProperty("myvalue", df.format(myvalue));
}

return rows;

 

 

Hope anyone can help, Thank you ..

datalists

4


16 Oct, 2018
confluenceUser
confluenceUser

Hi, the code you provided is not valid Java. If you look at the Bean Shell Formatter page there is no need to define a store method. It just returns the formatted value so you could use some code like in https://stackoverflow.com/questions/12806278/double-decimal-formatting-in-java

16 Oct, 2018
confluenceUser
confluenceUser

Hi Anders,

It is easy to make 5744.9067000000005 to 5744.91 in a Form Builder.

But it is still not solved in a Datalist Builder.

Should i use Bean Shell Formatter or Javascript Condition Formatter ? and how ..

Thank you ..

17 Oct, 2018
confluenceUser
confluenceUser

Either formatter would work, depends on what scripting language you prefer. Bean Shell uses Java, the other uses JavaScript. You can search online for sample Java or JavaScript code to format decimals.

17 Oct, 2018
confluenceUser
confluenceUser

Hi Anders Thanks for the answer, several scripts from google with no success, my last effort : General > Action Mapping > Formatter > Configure Bean Shell Formatter DecimalFormat df = new DecimalFormat("#.00"); row.setProperty("columname", df.format(columname));

RELATED QUESTIONS

Your answer


To answer a question you'll need an account.

Print