Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
1810
currency format managing decimal points
posted

Hi Team

I am looking for very urgent quick help

i have columns applied currency format, is there any way to have one column with two decimal which is default but another column with three decimal and another with four decimal.

I understand that $.ig.regional.defaults i have to set min/max value for currency, suppose i set min to 0 and max to 9 and but how can we set dynamically column decimal value to according to my need for each column.

How can I achieve that.

I felt $.ig.formatter this can help me but didn't understand this function completely, since its not mentioned any documentation can you help me to understand this function.

I tried this but didn't worked $.ig.formatter(9332.44567889, "number", "currency",null,null,'0.00')


Your ASAP response will be very helpful for me.


Thanks

Parents Reply
  • 17590
    Offline posted in reply to Prakash

    Hello ptilwani,

    Thank you for posting in our community.

    As you assumed formatter function will help you achieve your requirement. As mentioned in our API documentation formatter is a reference to a function(string or function) which will be used for formatting the cell values of particular column. The function should accept value and return new formatted value.

    I made a small sample illustrating how your requirement could be achieved using formatter option of the columns. Since formatter is set per column you can format every column differently and get the look and feel that you are looking form. In my sample I am using 3 formatter to return the values with 2,3 and 4 decimal placed. In this scenario data type number is preserved and sorting and filtering behavior are working as expected for this type of data For example:

    [code]

     $("#grid").igGrid({
                    columns: [
                        { headerText: "Name", key: "Name", dataType: "string" },
                        { headerText: "Age", key: "Age", dataType: "number" },
                        { headerText: "Price1", key: "Price1", dataType: "number", formatter: function (val, data) { return "$" + val.toFixed(2)  } },
                        { headerText: "Price2", key: "Price2", dataType: "number", formatter: function (val, data) { return "$" + val.toFixed(3) } },
                        { headerText: "Price3", key: "Price3", dataType: "number", formatter: function (val, data) { return "$" + val.toFixed(4) } }
                    ],
                    dataSource: data //JSON Array defined above                    
                });

    [/code]

    I am also attaching my sample for your reference.

    Please keep in mind that according to our Support Policy the response time for your cases and forum posts depends on the support level that you have. In you scenario the support level is "Standard" which means that the actual response is expected within 3 business days. If you would like to take advantage of our Priority support and receive responses with 24 ours please contact our sales department at: sales@infragistics.com

    Thank you for using Infragistics components.

    igGridFormatCurrencyColumns.zip
Children