Custom Grid Cell Type for % mask

I am trying to create a column that is editable numeric field.

Based on the other column field, I would like to change the type.

For example, if the column_1 = ‘Percentage’

then I want my custom_column to show 99.99 suffixed with ‘%’ sign.

else for any other column_1 values, just show a numeric value with 2 decimal places.

My logic is:

function eXcell_myedn(cell) {
	this.base = eXcell_edn;
	this.setValue = function(val) {
		if (!val || val.toString()._dhx_trim() == "")
			val = "";
		else {
			val = val + "%";
			this.cell.innerHTML = this.grid._aplNF(val, this.cell._cellIndex);
eXcell_myedn.prototype = new eXcell_edn;

My grid initialization looks like:


grid.attachEvent(“onCellChanged”, function(id, ind, value) {

if (ind == 6) {
	var metricType = grid.cellById(id, 3).getValue();
	grid._ignore_next = true;
	if (metricType == "Percentage" && value) {
		grid.setCellExcellType(id, ind, "myedn");
	if (!value || value.toString()._dhx_trim() == "0.00" && metricType != "Percentage")
		grid.setCellExcellType(id, ind, "ed");

           grid._ignore_next = false;

The following logic doesn’t work and ‘%’ sign does not get suffixed at the end of a Floating value in my column.

any help would be appreciated.

To add a few things to my original post,

What I am trying to achieve is a 2 decimal places & thousand place separator for all the values.

so I need to use the API - grid.setNumberFormat(“0,000.00”, col_name, “.”, “,”);

But the problem is when I try to concatenate “%” to the Percentage type CELL, it puts NaN on the grid.

That’s the reason I am using grid.setCellExcellType() but still doesn’t help me to concatenate “%” to the end of the number.

Need your help please

Please, try to use:

grid.setNumberFormat("0,000.00%", col_name, ".", ",");

to add a percentage symbol after the number.