Different Currency Symbols for different rows in datagrid

Hi,

In datagrid, based on another record values I've to set the currency symbols.

For eg,

If the first row and column one has an Id =25, then value on 1st row and 2nd column be dollars(85$) and for the next set if it has id =30, then it must be euros(780 € ). So it would be like as follows:

Id    Cost

1      85$

2      80 € and so on.

Thanks for any help in advance.

var GridFunctionsCurrency = {
    
  currencyRenderer: function(panel, row, column, cell) {
        if (panel.cellType == wijmo.grid.CellType.Cell) { // Only for cells, exclude grid header
            var value = panel.getCellData(row, column);            
            var r = panel.rows[row].dataItem;
            var currency = r.CurrencySymbol;
            if (String(value).split(".").length < 2 || String(value).split(".")[1].length<=2 ){
            value = Number(value).toFixed(2);
             }
              if (value !== null && value !== undefined && !isNaN(value)) {                  
                var _val = currency + value.toString().replace(/(\d)(?=(\d{3})+(?!\d))/g, "$1,");                
                if (_val !== undefined && _val !== null && _val !== 'NaN') {
                return _val;
                }
            }
        }
    }
};

Using the cell renderer parameter, I've bound an attribute with currency symbol and concatenated the  symbol and the value. I've used the above script to achieve this
mvp_badge
MVP

Hi Balaji,

In this case you need to create one currency type static entity and store this Identifire in main entity when you save record.

Based on currency type you can add diffrent currency symbol in grid.


Hope thsi will help you.

Regards

Rahul

Rahul Sahu wrote:

Hi Balaji,

In this case you need to create one currency type static entity and store this Identifire in main entity when you save record.

Based on currency type you can add diffrent currency symbol in grid.


Hope thsi will help you.

Regards

Rahul

 Hi Rahul,

I've a column with currency symbol and how do I get the value with the currency symbol in datagrid. Should I have a function and if so how do I pass the parameter or is there any any other way to apply directly on the Columncurrency webblock

 

Hi,  

The FormatCurrency(,,,,) function formats your number and the second parameter is the currency symbol, it should be something like this : 

FormatCurrency(Value , if(Id=25,"$",If(Id=30,"€","?")),NumberOfDigits,DecimalSeparator,GroupSeparator))

Hope this helps

Graça 

 

Maria da Graça Peixoto wrote:

Hi,  

The FormatCurrency(,,,,) function formats your number and the second parameter is the currency symbol, it should be something like this : 

FormatCurrency(Value , if(Id=25,"$",If(Id=30,"€","?")),NumberOfDigits,DecimalSeparator,GroupSeparator))

Hope this helps

Graça 

 

 Hi Maria,

I know this function but what I'm asking is to apply the symbol in columnCurrency in data grid forge component. In that, there's a parameter for currency symbol and I want my symbol to dynamic based on values on other columns. I've attached a  screenshot.

 

GridColumnCurrency.png

mvp_badge
MVP

Hi Balaji,

you are setting condition from ID and id can be change from environment wise that not good practise.

Well @Maria alredy provide suggestion.


Regards

Rahul

Rahul Sahu wrote:

Hi Balaji,

you are setting condition from ID and id can be change from environment wise that not good practise.

Well @Maria alredy provide suggestion.


Regards

Rahul

 HI Rahul,


     I guess the poster want to know how to achieve it based on forge DataGrid. It would be not easy to get the id and/or other column info from each row directly. 

 Regards,

Zhou Shuai

Why not pass to the DataGrid the amount as text field with the value already formatted ? 

As they are from different currencies you are not going to do calculations with that column.


Maria da Graça Peixoto wrote:

Why not pass to the DataGrid the amount as text field with the value already formatted ? 

As they are from different currencies you are not going to do calculations with that column.


 

 Actually I'm going to edit the values in the column and so I want to retain the symbol with the values in the grid. For getting the data it can be applied but if I want to edit and save the data, I need the symbol to be retained.


var GridFunctionsCurrency = {
    
  currencyRenderer: function(panel, row, column, cell) {
        if (panel.cellType == wijmo.grid.CellType.Cell) { // Only for cells, exclude grid header
            var value = panel.getCellData(row, column);            
            var r = panel.rows[row].dataItem;
            var currency = r.CurrencySymbol;
            if (String(value).split(".").length < 2 || String(value).split(".")[1].length<=2 ){
            value = Number(value).toFixed(2);
             }
              if (value !== null && value !== undefined && !isNaN(value)) {                  
                var _val = currency + value.toString().replace(/(\d)(?=(\d{3})+(?!\d))/g, "$1,");                
                if (_val !== undefined && _val !== null && _val !== 'NaN') {
                return _val;
                }
            }
        }
    }
};

Using the cell renderer parameter, I've bound an attribute with currency symbol and concatenated the  symbol and the value. I've used the above script to achieve this
Community GuidelinesBe kind and respectful, give credit to the original source of content, and search for duplicates before posting.