[CLOSED] NumberColumn is not showing 1 decimal values ,if there is Render funcation for the gridPanel

  1. #1

    [CLOSED] NumberColumn is not showing 1 decimal values ,if there is Render funcation for the gridPanel

    HI Daniil


    NumberColumn is not showing 1 decimal values ,if there is Render function for the gridPanel

    Please find the code and screenshot
    <%@ Page Language="C#" AutoEventWireup="true" %>
    
    <%@ Import Namespace="System.Xml" %>
    <%@ Import Namespace="System.Collections.Generic" %>
    <%@ Import Namespace="System.Data.SqlClient" %>
    <%@ Import Namespace="System.Data" %>
    <%@ Import Namespace="Ext.Net" %>
    <%@ Register Assembly="Ext.Net" Namespace="Ext.Net" TagPrefix="ext" %>
    
    <script runat="server"> 
     
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!X.IsAjaxRequest)
            {
                try
                {
                    BindRecords();
                }
                catch (System.Data.SqlClient.SqlException ex)
                {
                    string strin = ex.ToString();
                }
            }
        }
    
        public void BindRecords()
        {
            DataTable dtSpiCpi = new DataTable();
            dtSpiCpi.Locale = System.Globalization.CultureInfo.InvariantCulture;
            dtSpiCpi.Columns.Add("Type", typeof(string));
            dtSpiCpi.Columns.Add("Jan", typeof(decimal));
            dtSpiCpi.Columns.Add("Feb", typeof(decimal));
            dtSpiCpi.Columns.Add("Mar", typeof(decimal));
            dtSpiCpi.Columns.Add("Apr", typeof(decimal));
    
            DataRow objRow = null;
    
            for (int index = 1; index <= 12; index++)
            {
                objRow = dtSpiCpi.NewRow();
                objRow["Type"] = index + "Jan15";
    
                if (index < 3)
                {
                    //objRow["Jan"] = Convert.ToDecimal("2.50");
                    objRow["Feb"] = Convert.ToDecimal("2.10");
                    objRow["Mar"] = Convert.ToDecimal("2.00");
                    objRow["Apr"] = Convert.ToDecimal("1.0");
                }
                else if (index < 5)
                {
                    objRow["Jan"] = Convert.ToDecimal("1.0");
                    objRow["Feb"] = Convert.ToDecimal("2.0");
                    objRow["Mar"] = Convert.ToDecimal("3.0");
                    objRow["Apr"] = Convert.ToDecimal("4.0");
                }
                else if (index < 7)
                {
                    objRow["Mar"] = Convert.ToDecimal("9.0");
                    objRow["Jan"] = Convert.ToDecimal("3.0");
                    objRow["Feb"] = Convert.ToDecimal("2.0");
                    objRow["Apr"] = Convert.ToDecimal("3.0");
    
                }
                else
                {
                    objRow["Jan"] = Convert.ToDecimal("4.9");
                    objRow["Feb"] = Convert.ToDecimal("3.0");
                    objRow["Mar"] = Convert.ToDecimal("2.0");
                    objRow["Apr"] = Convert.ToDecimal("1.0");
    
                }
                dtSpiCpi.Rows.Add(objRow);
            }
    
            storeSpiCpi.RemoveAll();
            storeSpiCpi.DataSource = dtSpiCpi;
            storeSpiCpi.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 id="Head1" runat="server">
        <title>Submit MultiSelect Values - Ext.NET Examples</title>
        <script type="text/javascript" language="javascript">
    
            function ManpowerAllocation_Renderer(columnValue, columnValueCls, record, rowIndex, columnNumber) {
    
                var columnIndex = columnValueCls.columnIndex;
                var forecolor;
                var backGroundcolor;
    
                switch (columnIndex) {
                    case 13:
                        if (rowIndex == 6) {
                            backGroundcolor = '#FFFFFF';
                        }
                        else {
                            backGroundcolor = '#ededee';
                        }
                        break;
                    default:
                        break;
    
                        var cssString = "background-color:{0};text-align:right;font: bold 8.5pt Arial, verdana, helvetica;";
                        cssString = String.format(cssString, backGroundcolor, forecolor);
                        columnValueCls.style = cssString;
                        
                }
                return columnValue;
            }
    
             
        </script>
    </head>
    <body>
        <form id="Form1" runat="server">
            <ext:ResourceManager ID="ResourceManager1" runat="server" Namespace="" />
            <table border="1">
                <tr>
                    <td>
                        <ext:GridPanel ID="grdFillRatePercentage" runat="server" Width="500" Height="350" Flex="1" AutoScroll="true" EnableColumnMove="false">
                            <Store>
                                <ext:Store ID="storeSpiCpi" runat="server">
                                    <Model>
                                        <ext:Model ID="Model38" runat="server">
                                            <Fields>
                                                <ext:ModelField Name="Type" />
                                                <ext:ModelField Name="Jan" />
                                                <ext:ModelField Name="Feb" />
                                                <ext:ModelField Name="Mar" />
                                                <ext:ModelField Name="Apr" />
                                            </Fields>
                                        </ext:Model>
                                    </Model>
                                </ext:Store>
                            </Store>
                            <ColumnModel ID="ColumnModel2" runat="server">
                                <Columns>
                                    <ext:Column ID="Column70" Sortable="false" runat="server" Text="" Resizable="false"
                                        MenuDisabled="true">
                                        <Columns>
                                            <ext:Column Height="20px" ID="Column88" runat="server" DataIndex="Type" Text="Type" Width="160" MenuDisabled="true" Sortable="false" Resizable="false" TdCls="boldClass" />
                                            <ext:NumberColumn Height="20px" ID="Column89" runat="server" Text="Jan" DataIndex="Jan" Width="80" Resizable="true" Sortable="false"
                                                MenuDisabled="true" Align="Right" Format="0.0">
                                                <Renderer Fn="ManpowerAllocation_Renderer" />
                                            </ext:NumberColumn>
                                            <ext:Column Height="20px" ID="Column90" Text="Feb" runat="server" DataIndex="Feb" Width="80" Resizable="true" Sortable="false"
                                                MenuDisabled="true" Align="Right">
                                            </ext:Column>
                                            <ext:Column ID="Column91" runat="server" Text="Mar" DataIndex="Mar" Width="80" Resizable="true" Sortable="false"
                                                MenuDisabled="true" Align="Right">
                                            </ext:Column>
                                            <ext:Column ID="Column92" runat="server" Text="Apr" DataIndex="Apr" Width="80" Resizable="true" Sortable="false"
                                                MenuDisabled="true" Align="Right">
                                            </ext:Column>
                                        </Columns>
                                    </ext:Column>
                                </Columns>
                            </ColumnModel>
                            <View>
                                <ext:GridView ID="grdViewFillRatePercentage" runat="server" StripeRows="false" TrackOver="false" />
                            </View>
                        </ext:GridPanel>
                    </td>
                </tr>
            </table>
        </form>
    </body>
    </html>
    Attached Thumbnails Click image for larger version. 

Name:	1Decimal.png 
Views:	57 
Size:	12.4 KB 
ID:	24212  
    Last edited by Daniil; Sep 07, 2015 at 4:26 PM. Reason: [CLOSED]
  2. #2
    Hi @praveencat123,

    A NumberColumn doesn't support a custom Renderer, because it uses its own custom Renderer which is defined internally.

    You can switch to a regular Column and replace
    return columnValue;
    with
    return Ext.util.Format.number(columnValue, "0.0");
    in the Renderer function.
  3. #3
    Thanks daniil...Its working

Similar Threads

  1. [CLOSED] Decimal point values in Grid panel
    By sundarsureshin in forum 3.x Help
    Replies: 2
    Last Post: Feb 10, 2015, 11:06 AM
  2. [CLOSED] ComboBox added values are not showing.
    By rnachman in forum 1.x Legacy Premium Help
    Replies: 2
    Last Post: Mar 29, 2013, 12:45 PM
  3. [CLOSED] hide decimal values on chart markers
    By RCM in forum 2.x Legacy Premium Help
    Replies: 11
    Last Post: Jan 30, 2013, 4:24 PM
  4. [CLOSED] Grid Column Renderer funcation called twice
    By randy85253 in forum 1.x Legacy Premium Help
    Replies: 15
    Last Post: Jan 09, 2012, 9:55 PM
  5. [CLOSED] How to make a NumberColumn look as an integer instead of decimal?
    By flormariafr in forum 1.x Legacy Premium Help
    Replies: 1
    Last Post: Jul 09, 2010, 8:45 PM

Tags for this Thread

Posting Permissions