[CLOSED] number renderer in grid column

  1. #1

    [CLOSED] number renderer in grid column

    hi...
    im using this
    <Renderer Fn="Ext.util.Format.numberRenderer('0,000.00')" />
    number render function in grid columns....but it is not displaying in indian number format

    for example 452136578912.00
    if i use this
    <Renderer Fn="Ext.util.Format.numberRenderer('0,000.00')" />
    it will display like this 452,136,578,912.00.......
    but i want it in indian currency format ,like this 4,52,13,65,78,912.00

    i have tried this
    <Renderer Fn="Ext.util.Format.numberRenderer('00,00,000.00')" />
    but no use...
    Last edited by Daniil; Dec 06, 2010 at 8:14 PM. Reason: Please use [CODE] tags, [CLOSED]
  2. #2
    I think you must create a custom Renderer Handler/Fn to handle this scenario. The formatting pattern you require is not included in Ext.NET/ExtJS.

    Hope this helps.
    Geoffrey McGill
    Founder & CEO
  3. #3
    Quote Originally Posted by geoffrey.mcgill View Post
    I think you must create a custom Renderer Handler/Fn to handle this scenario. The formatting pattern you require is not included in Ext.NET/ExtJS.

    Hope this helps.
    how to create a custom Renderer Handler/Fn..plz give me example
  4. #4
    Hi,

    Here is an example.
    http://forums.ext.net/showthread.php...D-Euro-in-grid

    With minor changes it can look like this:

    Example
    <%@ Page Language="C#" %>
     
    <%@ Register Assembly="Ext.Net" Namespace="Ext.Net" TagPrefix="ext" %>
     
    <script runat="server">
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!X.IsAjaxRequest)
            {
                Store store = this.GridPanel1.GetStore();
                store.DataSource = new object[]
                {
                    new object[] { 200000.12 },
                    new object[] { -1123.42 },
                    new object[] { 3.42 },
                    new object[] { -0.42 },
                    new object[] { -42.456 },
                    new object[] { 10000042.456 },
                    new object[] { -99000042.456 },
                    new object[] { 99000042.451 },
                    new object[] { 32.429 },                         
                    new object[] { 15300.99 },
                    new object[] { -15300.99 },
                    new object[] { -5199.98 },
                    new object[] { 5199.98 }
                };
                store.DataBind();
            }
        }
    </script>
     
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
        "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml">
    <head runat="server">
        <title>Ext.Net Example</title>
     
        <script type="text/javascript">
            var indMoney = function(v) {
                v = (Math.round((v - 0) * 100)) / 100;
                v = (v == Math.floor(v)) ? v + ".00" : ((v * 10 == Math.floor(v * 10)) ? v + "0" : v);
                v = String(v);
                var ps = v.split('.'),
                    whole = ps[0],
                    sub = ps[1] ? '.' + ps[1] : '.00',
                    r = /(\d+)(\d{2})/;
                while (r.test(whole)) {
                    whole = whole.replace(r, '$1' + ',' + '$2');
                }
                v = whole + sub;
     
                return v;
            }
        </script>
    </head>
    <body>
        <form runat="server">
        <ext:ResourceManager runat="server" />
        <ext:GridPanel ID="GridPanel1" runat="server" AutoHeight="true">
            <Store>
                <ext:Store runat="server">
                    <Reader>
                        <ext:ArrayReader>
                            <Fields>
                                <ext:RecordField Name="money" />
                            </Fields>
                        </ext:ArrayReader>
                    </Reader>
                </ext:Store>
            </Store>
            <ColumnModel runat="server">
                <Columns>
                    <ext:Column Header="ind" DataIndex="money">
                        <Renderer Handler="return indMoney(value);" />
                    </ext:Column>
                    <ext:Column Header="usd" DataIndex="money">
                        <Renderer Format="UsMoney" />
                    </ext:Column>
                </Columns>
            </ColumnModel>
        </ext:GridPanel>
        </form>
    </body>
    </html>
  5. #5
    Quote Originally Posted by Daniil View Post
    Hi,

    Here is an example.
    http://forums.ext.net/showthread.php...D-Euro-in-grid

    With minor changes it can look like this:

    Example
    <%@ Page Language="C#" %>
     
    <%@ Register Assembly="Ext.Net" Namespace="Ext.Net" TagPrefix="ext" %>
     
    <script runat="server">
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!X.IsAjaxRequest)
            {
                Store store = this.GridPanel1.GetStore();
                store.DataSource = new object[]
                {
                    new object[] { 200000.12 },
                    new object[] { -1123.42 },
                    new object[] { 3.42 },
                    new object[] { -0.42 },
                    new object[] { -42.456 },
                    new object[] { 10000042.456 },
                    new object[] { -99000042.456 },
                    new object[] { 99000042.451 },
                    new object[] { 32.429 },                         
                    new object[] { 15300.99 },
                    new object[] { -15300.99 },
                    new object[] { -5199.98 },
                    new object[] { 5199.98 }
                };
                store.DataBind();
            }
        }
    </script>
     
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
        "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml">
    <head runat="server">
        <title>Ext.Net Example</title>
     
        <script type="text/javascript">
            var indMoney = function(v) {
                v = (Math.round((v - 0) * 100)) / 100;
                v = (v == Math.floor(v)) ? v + ".00" : ((v * 10 == Math.floor(v * 10)) ? v + "0" : v);
                v = String(v);
                var ps = v.split('.'),
                    whole = ps[0],
                    sub = ps[1] ? '.' + ps[1] : '.00',
                    r = /(\d+)(\d{2})/;
                while (r.test(whole)) {
                    whole = whole.replace(r, '$1' + ',' + '$2');
                }
                v = whole + sub;
     
                return v;
            }
        </script>
    </head>
    <body>
        <form runat="server">
        <ext:ResourceManager runat="server" />
        <ext:GridPanel ID="GridPanel1" runat="server" AutoHeight="true">
            <Store>
                <ext:Store runat="server">
                    <Reader>
                        <ext:ArrayReader>
                            <Fields>
                                <ext:RecordField Name="money" />
                            </Fields>
                        </ext:ArrayReader>
                    </Reader>
                </ext:Store>
            </Store>
            <ColumnModel runat="server">
                <Columns>
                    <ext:Column Header="ind" DataIndex="money">
                        <Renderer Handler="return indMoney(value);" />
                    </ext:Column>
                    <ext:Column Header="usd" DataIndex="money">
                        <Renderer Format="UsMoney" />
                    </ext:Column>
                </Columns>
            </ColumnModel>
        </ext:GridPanel>
        </form>
    </body>
    </html>
    ya its good...but it is not in indian currency format..

    10000042.456 for this it should display like this 1,00,00,042.46 but according to your function it is displaying like this 10,00,00,42.46
  6. #6
    Hi,

    If know how it should be displayed then just write renderer (as in the example below) which converts number to indian format
    Vladimir Shcheglov
    Sr. Developer

Similar Threads

  1. [CLOSED] Grid Column Renderer funcation called twice
    By randy85253 in forum 1.x Premium Help
    Replies: 15
    Last Post: Jan 09, 2012, 9:55 PM
  2. Grid Column Renderer
    By karthik.arian03 in forum 1.x Help
    Replies: 8
    Last Post: Feb 11, 2011, 6:34 AM
  3. [CLOSED] Number grid column format
    By Stefanaccio in forum 1.x Premium Help
    Replies: 15
    Last Post: Oct 27, 2010, 2:40 PM
  4. [CLOSED] Grid Column Renderer for Currency £
    By CMA in forum 1.x Premium Help
    Replies: 1
    Last Post: Sep 07, 2010, 4:52 PM
  5. [CLOSED] [1.0] Number format in Grid Column
    By bsnezw in forum 1.x Premium Help
    Replies: 1
    Last Post: Feb 09, 2010, 1:06 PM

Tags for this Thread

Posting Permissions