From 24b7137b1c17df5f2349265c56c66d61f38c300c Mon Sep 17 00:00:00 2001 From: Hadi Nategh Date: Fri, 8 Jan 2016 14:20:09 +0000 Subject: [PATCH] Add precision option to entry widget --- etemplate/js/et2_widget_entry.js | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/etemplate/js/et2_widget_entry.js b/etemplate/js/et2_widget_entry.js index 8bc24fdf88..a8408bc0b1 100644 --- a/etemplate/js/et2_widget_entry.js +++ b/etemplate/js/et2_widget_entry.js @@ -49,6 +49,12 @@ var et2_entry = et2_valueWidget.extend( type: 'string', default: et2_no_init }, + precision: { + name: 'Decimals to be shown', + description: 'Specifies the number of decimals on a float value, the default is 2', + type: 'string', + default: '2' + }, value: { type: 'any' }, @@ -148,6 +154,7 @@ var et2_entry = et2_valueWidget.extend( widget.options.value = sum; } } + if (this.options.precision) widget.options.value = parseFloat(widget.options.value).toFixed(this.options.precision); } });