Search code examples
asp.net-mvcextjsextjs4

How can I convert float to int in extJs controller


I have ASP.NET MVC application with ExtJs4 client side code. I'm new in ExtJs4. I have next code:

columns: [
    {
        text: 'Money',
        width: 150,
        sortable: false,
        dataIndex: 'Money'
    }

This code return value = 0000.00, because Money is a float variable but I need value = 0000. May I with some interactions convert float to int inside my rendered block without changing my Model?


Solution

  • Use a column renderer:

    {
        dataIndex: 'Money',
        renderer: Ext.util.Format.numberRenderer('0000')
    }
    

    Docs: http://docs.sencha.com/extjs/4.2.2/#!/api/Ext.util.Format-method-numberRenderer