Set precision of Decimal Datatype column to 5 decimal places

Hi,

I am using Creatio 7.14. I have a custom detail with a Price field of Decimal datatype. I know that we can define precision to 1, 2, 3, 4 or 8 decimal places. Is there a way to set it to 5? Attached is the image for the current setup of the detail.

Instead of displaying as 0.00003000, I need to display as 0.00003. 

I was able to achieve it in Detail Edit page by adding the below attribute to the field in diff:

"controlConfig": {

                        decimalPrecision: 5

                    }

 

I need to achieve the same in Detail Grid as well. I followed the community articles to create a module from scratch to extend Terrasoft.Grid:

https://community.creatio.com/questions/hyperlink-fields

https://community.creatio.com/questions/substitutionreplacing-modules

https://community.creatio.com/questions/custom-detail-hyperlink-get-fil…

 

-------------------------------------

define("UsrConfigurationGrid", ["Terrasoft.Grid"], function() {

    Ext.define("Terrasoft.configuration.UsrConfigurationGrid", {

        extend: "Terrasoft.Grid",

        alternateClassName: "Terrasoft.UsrConfigurationGrid",

        // change methods here 

        formatCellContent: function(htmlConfig, data, column) {

            if(column==="UsrTrtPrice")

            {

                data.UsrTrtPrice = parseFloat(data.UsrTrtPrice).toFixed(5);

            }

            return this.callParent(arguments);

        }

            

    });

    

    return Terrasoft.UsrConfigurationGrid;

});

-------------------------------------

Is this the correct way to do it? How should I proceed from here? Do I need to add "UsrConfigurationGrid" as a dependency in Detail Grid Page as:

----------------------------------------------

define("O1SessionDetailGrid", ["ConfigurationGrid", "ConfigurationGridGenerator",

    "ConfigurationGridUtilities","ProcessModuleUtilities","UsrConfigurationGrid"], function(ProcessModuleUtilities) {

    return {.......

----------------------------------------------

Should I remove "ConfigurationGrid" which was added to make the grid editable? The above setting does not seem to be working as the detail is not getting displayed after adding "UsrConfigurationGrid".

I would appreciate if anyone could provide any thoughts on this.

 

File attachments
Like 0

Like

2 comments
Best reply

Hi,

 

There is an easier way to achieve a custom precision for the column: in the grid detail schema you need to override the getGridRowViewModelConfig method. For example I've created a replacing view model for the OrderProductDetailV2 and specified the following code there:

define("OrderProductDetailV2", ["MoneyModule", "css!OrderPageV2Styles", "css!SummaryModuleV2"], function(MoneyModule) {
	return {
		entitySchemaName: "OrderProduct",
		messages: {},
		attributes: {},
		methods: {
			getGridRowViewModelConfig: function(config) {
				var gridRowViewModelConfig = this.callParent(arguments);
				gridRowViewModelConfig.rowConfig.UsrDecForTests.precision=6;
				return gridRowViewModelConfig;
			}
		},
		diff: /**SCHEMA_DIFF*/[]/**SCHEMA_DIFF*/
	};
});

In this case all the values in the precision for the "UsrDecForTests" decimal column (that is Decimal (0.00000001) data type) in the "Products" detail on the order page will be set to 6:

and

and

So you can try the following approach on your end.

 

Best regards,

Oscar

Hi,

 

There is an easier way to achieve a custom precision for the column: in the grid detail schema you need to override the getGridRowViewModelConfig method. For example I've created a replacing view model for the OrderProductDetailV2 and specified the following code there:

define("OrderProductDetailV2", ["MoneyModule", "css!OrderPageV2Styles", "css!SummaryModuleV2"], function(MoneyModule) {
	return {
		entitySchemaName: "OrderProduct",
		messages: {},
		attributes: {},
		methods: {
			getGridRowViewModelConfig: function(config) {
				var gridRowViewModelConfig = this.callParent(arguments);
				gridRowViewModelConfig.rowConfig.UsrDecForTests.precision=6;
				return gridRowViewModelConfig;
			}
		},
		diff: /**SCHEMA_DIFF*/[]/**SCHEMA_DIFF*/
	};
});

In this case all the values in the precision for the "UsrDecForTests" decimal column (that is Decimal (0.00000001) data type) in the "Products" detail on the order page will be set to 6:

and

and

So you can try the following approach on your end.

 

Best regards,

Oscar

That's exactly what I needed. Thank you, Oscar!

Show all comments