GridNumericColumn DecimalDigits

6 posts, 0 answers
  1. Pini Usha
    Pini Usha avatar
    2 posts
    Member since:
    Jul 2009

    Posted 07 May 2011 Link to this post

    Hi,
    I cannot make the DataFormatString to work. i tried to specify  with rounding without rounding with DecimalDigits with DataType="System.Decimal", NumericType="Number" 
    and it seems like it just always shows 3dp what ever I do.

    I need to make it 4dp.
    i read some posts about the edit, but i care only about the display.

    Thanks, Pini.

  2. Princy
    Princy avatar
    17421 posts
    Member since:
    Mar 2007

    Posted 09 May 2011 Link to this post

    Hello Pini,

    You can achieve this by setting DataFormatString property and set the format string. Try the following mark up.

    aspx:
    <telerik:GridNumericColumn UniqueName="Decimal" NumericType="Number" AllowRounding="false"
     HeaderText="Numeric" DataType="System.Decimal" DataField="decimal"
      DataFormatString="{0:f4}">
    </
    telerik:GridNumericColumn>

    Also check the following documentation which deals with Standard Numeric Format Strings.

    If you want the same in Edit mode, then you have to explicitly set the properties. Try the following code snippet by attaching ItemCreated event to your RadGrid.

    C#:
    protected void RadGrid1_ItemCreated(object sender, Telerik.Web.UI.GridItemEventArgs e)
       {
           if (e.Item is GridEditFormItem   && e.Item.IsInEditMode)
           {
           GridEditFormItem editItem = (GridEditFormItem)e.Item;
           RadNumericTextBox textbox = (RadNumericTextBox)editItem["Decimal"].Controls[0];
           textbox.NumberFormat.AllowRounding = false;
           textbox.NumberFormat.DecimalDigits = 4;
           
       }


    Thanks,
    Princy.
  3. UI for ASP.NET Ajax is Ready for VS 2017
  4. Pini Usha
    Pini Usha avatar
    2 posts
    Member since:
    Jul 2009

    Posted 09 May 2011 Link to this post

    No. Still getting 3dp. 
    here is the grid header:

    <telerik:RadGrid ID="RadGrid1" runat="server" AllowFilteringByColumn="True" AutoGenerateColumns="false"
                    AllowPaging="True" AllowSorting="false" DataSourceID="ObjectDataSource1" GridLines="None"
                    ShowGroupPanel="True" ShowFooter="true" AllowAutomaticDeletes="true" OnItemCommand="RadGrid1_ItemCommand"
                    HeaderStyle-HorizontalAlign="Center">
                    <ClientSettings AllowDragToGroup="True" ReorderColumnsOnClient="True">
                        <Selecting AllowRowSelect="True" />
                    </ClientSettings>
                    <FilterItemStyle Width="50px" />
                    <ExportSettings IgnorePaging="true" OpenInNewWindow="true" FileName="Transactions"
                        ExportOnlyData="true">
                        <Pdf PageTitle="Transactions" PageWidth="297mm" PageHeight="210mm" FontType="Subset"
                            Producer="Treashares.com" AllowPrinting="true" />
                    </ExportSettings>
                    <GroupingSettings RetainGroupFootersVisibility="true" ShowUnGroupButton="true" />
                    <MasterTableView DataSourceID="ObjectDataSource1" DataKeyNames="Id" ShowGroupFooter="true"
                        CommandItemDisplay="Top">
  5. Mira
    Admin
    Mira avatar
    1124 posts

    Posted 12 May 2011 Link to this post

    Hello Pini,

    Could you please send us the declaration of the problematic column?
    We will examine it and get back to you with our suggestions for fixing the issue.

    Kind regards,
    Mira
    the Telerik team

    Browse the vast support resources we have to jump start your development with RadControls for ASP.NET AJAX. See how to integrate our AJAX controls seamlessly in SharePoint 2007/2010 visiting our common SharePoint portal.

  6. Marco Teodoro
    Marco Teodoro avatar
    53 posts
    Member since:
    Apr 2010

    Posted 25 Jul 2011 Link to this post

    hello i'm trying to set a decimal column to show itens using only 3 decimal characters.

    How can i achieve this?

    here is my code:

    <telerik:GridNumericColumn DataField="xxx" DataType="System.Decimal"
                            HeaderText="xxx"  SortExpression="xxx"
                            UniqueName="xxx" DecimalDigits="3">
                        </telerik:GridNumericColumn>

    i also tried this:

    protected void RadGrid1_ItemCreated(object sender, Telerik.Web.UI.GridItemEventArgs e)
       {
           if (e.Item is GridEditFormItem   && e.Item.IsInEditMode)
           {
           GridEditFormItem editItem = (GridEditFormItem)e.Item;
           RadNumericTextBox textbox = (RadNumericTextBox)editItem["xxx"].Controls[0];
           textbox.NumberFormat.DecimalDigits = 3;
           
       }
    this should be really easy. how can i do it?

    best regards, 

    Marco

  7. Vasil
    Admin
    Vasil avatar
    1547 posts

    Posted 28 Jul 2011 Link to this post

    Hi Marco,

    The declaration that you use seems to be correct. Could you confirm that RadGrid1_ItemCreated is registered as event handler for ItemCreated of your grid?
    Also could you check what is the type of the data field in the database that you are using? If it is nvarchar(or other string type) instead of 'decimal' (or some other numeric) you will face formatting problems.

    Best wishes,
    Vasil
    the Telerik team

    Browse the vast support resources we have to jump start your development with RadControls for ASP.NET AJAX. See how to integrate our AJAX controls seamlessly in SharePoint 2007/2010 visiting our common SharePoint portal.

Back to Top
UI for ASP.NET Ajax is Ready for VS 2017