GridNumericColumn with Decimal Digits when Edit

32 posts, 1 answers
  1. Henrique Duarte
    Henrique Duarte avatar
    104 posts
    Member since:
    Oct 2003

    Posted 19 Dec 2008 Link to this post

    Guys,

    How can I set decimal digits to a GridNumericColumn when  inserting/editing a record (NumericTextBox)?
    I alredy have set the DataFormatString = "{0:C2}", but the grid ignores the format when edit mode.

    <telerik:GridNumericColumn NumericType="Currency"  DataField="Valor" DataType="System.Decimal" HeaderText="Valor" SortExpression="Valor" UniqueName="Valor" DataFormatString="{0:C2}">  
        <ItemStyle HorizontalAlign="Right"></ItemStyle> 
    </telerik:GridNumericColumn> 

    Regards,

    Henrique
  2. Daniel
    Admin
    Daniel avatar
    4946 posts

    Posted 20 Dec 2008 Link to this post

    Hello Henrique,

    You can easily control the way the numbers are formatted using GridTemplateColumn and RadNumericTextBox control.
    <telerik:GridTemplateColumn HeaderText="Valor" SortExpression="Valor" UniqueName="Valor"
        <ItemStyle HorizontalAlign="Right"></ItemStyle> 
        <ItemTemplate> 
            ... 
        </ItemTemplate> 
        <EditItemTemplate> 
            <telerik:RadNumericTextBox ID="RadNumericTextBox1" runat="server" DataType="System.Decimal" 
                Value='<%# Bind("Valor") %>' Type="Currency" NumberFormat-DecimalDigits="2" /> 
        </EditItemTemplate> 
    </telerik:GridTemplateColumn> 

    Please let us know whether this suits your scenario.

    Best regards,
    Daniel
    the Telerik team

    Check out Telerik Trainer, the state of the art learning tool for Telerik products.
  3. UI for ASP.NET Ajax is Ready for VS 2017
  4. Henrique Duarte
    Henrique Duarte avatar
    104 posts
    Member since:
    Oct 2003

    Posted 20 Dec 2008 Link to this post

    Hello Daniel,

    If I have a GridNumericColumn, why will I use a GridTemplateColumn???
    I'll treat like a workaround and report a bug.

    Thanks,

    Henrique
  5. Daniel
    Admin
    Daniel avatar
    4946 posts

    Posted 22 Dec 2008 Link to this post

    Hello Henrique,

    I answered your Bug Report ticket. We will inform the community when we have some progress on the matter.

    Best regards,
    Daniel
    the Telerik team

    Check out Telerik Trainer, the state of the art learning tool for Telerik products.
  6. Answer
    Daniel
    Admin
    Daniel avatar
    4946 posts

    Posted 23 Dec 2008 Link to this post

    Hello Henrique,

    Our developers added AllowRounding and KeepNotRoundedValue properties to GridNumericColumn.

    You can expect the new changes in the next release - RadControls for ASP.NET AJAX Q3 2008 SP2 in the middle of January.

    Thank you for your cooperation.

    Best regards,
    Daniel
    the Telerik team

    Check out Telerik Trainer, the state of the art learning tool for Telerik products.
  7. Jesper
    Jesper avatar
    2 posts
    Member since:
    Aug 2008

    Posted 01 Jul 2009 Link to this post

    It would be appropriate to also add the DecimalDigits to the Column, in fact as the wrapper it is it ought to expose every special property of the RadNumericTextbox.

    Brgds,
    Thomas Scheelhardt
  8. Nikolay Rusev
    Admin
    Nikolay Rusev avatar
    2285 posts

    Posted 06 Jul 2009 Link to this post

    Hello Flemming,

    Indeed you are right about the wrapper.
    We will add the property to GridNumericColumn  and it will available in one of the future builds.

    All the best,
    Nikolay
    the Telerik team

    Instantly find answers to your questions on the new Telerik Support Portal.
    Check out the tips for optimizing your support resource searches.
  9. waruni
    waruni avatar
    27 posts
    Member since:
    Jan 2008

    Posted 10 Nov 2010 Link to this post

    HI,

    I also have the same problem, i need GridNumericColumn which support the DecimalDigits.
    Don't you have that decimal feature in RadControls for ASP.NET AJAX Q2 2010.

    regards
    waruni

  10. Veli
    Admin
    Veli avatar
    2002 posts

    Posted 10 Nov 2010 Link to this post

    Hello waruni,

    The GridNumericColumn.DecimalDigits property will be implemented for the 2010 Q3 SP1 release of Telerik RadControls for ASP.NET AJAX.

    Veli
    the Telerik team
    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
  11. Jerry T.
    Jerry T. avatar
    118 posts
    Member since:
    Jul 2012

    Posted 16 Dec 2010 Link to this post

    InPlace editing of a GridNumericColumn still won't show the proper number of decimal places:

    Here is the grid markup:
    <telerik:RadGrid ID="radgrdProgramServiceCostingSheet" runat="server" Width="980px" DataSourceID="odsGetServiceCostingSheet" EnableLinqExpressions="true"
        ShowStatusBar="true" AllowAutomaticUpdates="false"
        AutoGenerateColumns="false" AllowFilteringByColumn="false" AllowPaging="false" AllowSorting="true">
        <ClientSettings EnableRowHoverStyle="true" Selecting-AllowRowSelect="true" Scrolling-AllowScroll="true" Scrolling-ScrollHeight="280px" EnablePostBackOnRowClick="true" /> <%--ClientEvents-OnPopUpShowing="CostingSheetEditPopUpShowing" --%>
        <GroupingSettings CaseSensitive="false" />
        <MasterTableView TableLayout="Fixed" DataKeyNames="fldCostingSheetID,fldCostingSheetHeaderID,fldServiceVenueItemID,fldCostPerUnit,fldUnits,fldHours,fldGratuity,GP,fldTax,fldTaxable,PricingOption,BillType,fldPricingOptionID,fldBilltype" EditMode="InPlace" > <%--EditFormSettings-PopUpSettings-Modal="true"--%>
            <HeaderStyle HorizontalAlign="Left" />
            <ItemStyle Wrap="false" />
            <AlternatingItemStyle Wrap="false" />
            <Columns>
                <telerik:GridEditCommandColumn ButtonType="LinkButton" HeaderStyle-CssClass="radGridViewHeader" HeaderStyle-Width="45px" EditText="" UpdateText="" CancelText="" UniqueName="EditButton" />
                <telerik:GridBoundColumn DataField="Category" HeaderText="Cat" SortExpression="Category" HeaderStyle-CssClass="radGridViewHeader" HeaderStyle-Width="48px" UniqueName="Category" />
                <telerik:GridBoundColumn DataField="VendorName" HeaderText="Vendor" SortExpression="VendorName" HeaderStyle-CssClass="radGridViewHeader" HeaderStyle-Width="135px" UniqueName="VendorName" />
                <telerik:GridBoundColumn DataField="fldCostingItem" HeaderText="Costing Item" SortExpression="fldCostingItem" HeaderStyle-CssClass="radGridViewHeader" HeaderStyle-Width="125px" UniqueName="fldCostingItem" />
                <telerik:GridNumericColumn DataField="fldCostPerUnit" HeaderText="Unit Cost" SortExpression="fldCostPerUnit" DataFormatString="{0:C2}" HeaderStyle-CssClass="radGridViewHeader" HeaderStyle-HorizontalAlign="Center" ItemStyle-HorizontalAlign="Right" HeaderStyle-Width="80px" UniqueName="fldCostPerUnit" DecimalDigits="2" NumericType="Currency" KeepNotRoundedValue="true" />
                <telerik:GridNumericColumn DataField="fldHours" HeaderText="Hrs" SortExpression="fldHours" HeaderStyle-CssClass="radGridViewHeader" HeaderStyle-HorizontalAlign="Center" ItemStyle-HorizontalAlign="Right" HeaderStyle-Width="30px" UniqueName="fldHours" />
                <telerik:GridBoundColumn DataField="fldGratuity" HeaderText="Grat" SortExpression="fldGratuity" HeaderStyle-CssClass="radGridViewHeader" HeaderStyle-HorizontalAlign="Center" ItemStyle-HorizontalAlign="Right" HeaderStyle-Width="30px" UniqueName="fldGratuity" />
                <telerik:GridBoundColumn DataField="fldUnits" HeaderText="Units" SortExpression="fldUnits" HeaderStyle-CssClass="radGridViewHeader" HeaderStyle-HorizontalAlign="Center" ItemStyle-HorizontalAlign="Right" HeaderStyle-Width="30px" UniqueName="fldUnits" />
                <telerik:GridBoundColumn DataField="fldTax" HeaderText="Tax" SortExpression="fldTax" HeaderStyle-CssClass="radGridViewHeader" HeaderStyle-HorizontalAlign="Center" ItemStyle-HorizontalAlign="Right" HeaderStyle-Width="35px" UniqueName="fldTax" />
                <telerik:GridCheckBoxColumn DataField="fldTaxable" HeaderText="Tax?" SortExpression="fldTaxable" HeaderStyle-CssClass="radGridViewHeader" HeaderStyle-Width="35px" UniqueName="fldTaxable" />
                <telerik:GridBoundColumn DataField="fldCost" HeaderText="Cost" SortExpression="fldCost" DataFormatString="{0:C2}" HeaderStyle-CssClass="radGridViewHeader" ItemStyle-HorizontalAlign="Right" HeaderStyle-Width="110px" UniqueName="fldCost" />
                <telerik:GridBoundColumn DataField="GP" HeaderText="GP" SortExpression="GP" DataFormatString="{0:0%}" HeaderStyle-CssClass="radGridViewHeader" HeaderStyle-HorizontalAlign="Center" ItemStyle-HorizontalAlign="Right" HeaderStyle-Width="35px" UniqueName="GP" />
                <telerik:GridBoundColumn DataField="fldUnitRev" HeaderText="Unit Rev" SortExpression="fldUnitRev" DataFormatString="{0:C2}" HeaderStyle-CssClass="radGridViewHeader" HeaderStyle-HorizontalAlign="Center" ItemStyle-HorizontalAlign="Right" HeaderStyle-Width="80px" UniqueName="fldUnitRev" />
                <telerik:GridBoundColumn DataField="PricingOption" HeaderText="Pricing Opt" SortExpression="PricingOption" HeaderStyle-CssClass="radGridViewHeader" HeaderStyle-Width="55px" UniqueName="PricingOption" />
                <telerik:GridBoundColumn DataField="fldRevenue" HeaderText="Revenue" SortExpression="fldRevenue" DataFormatString="{0:C2}" HeaderStyle-CssClass="radGridViewHeader" HeaderStyle-HorizontalAlign="Center" ItemStyle-HorizontalAlign="Right" HeaderStyle-Width="110px" UniqueName="fldRevenue" />
                <telerik:GridBoundColumn DataField="fldRevPerPerson" HeaderText="Rev PP" SortExpression="fldRevPerPerson" DataFormatString="{0:C2}" HeaderStyle-CssClass="radGridViewHeader" HeaderStyle-HorizontalAlign="Center" ItemStyle-HorizontalAlign="Right" HeaderStyle-Width="95px" UniqueName="fldRevPerPerson" />
                <telerik:GridBoundColumn DataField="CommOption" HeaderText="Comm" SortExpression="CommOption" HeaderStyle-CssClass="radGridViewHeader" HeaderStyle-Width="80px" UniqueName="CommOption" />
                <telerik:GridBoundColumn DataField="BillType" HeaderText="Bill Type" SortExpression="BillType" HeaderStyle-CssClass="radGridViewHeader" HeaderStyle-Width="80px" UniqueName="BillType" />
                <telerik:GridBoundColumn DataField="fldGroupType" HeaderText="Group" SortExpression="fldGroupType" HeaderStyle-CssClass="radGridViewHeader" HeaderStyle-Width="50px" ItemStyle-HorizontalAlign="Right" UniqueName="fldGroupType" />
                <telerik:GridBoundColumn DataField="fldSortOrder" HeaderText="Sort" SortExpression="fldSortOrder" HeaderStyle-CssClass="radGridViewHeader" HeaderStyle-Width="40px" ItemStyle-HorizontalAlign="Right" UniqueName="fldSortOrder" />
                <telerik:GridBoundColumn DataField="fldTax1" UniqueName="fldTax1" Visible="false" ReadOnly="true" />
                <telerik:GridBoundColumn DataField="fldTax2" UniqueName="fldTax2" Visible="false" ReadOnly="true" />
            </Columns>
        </MasterTableView>
    </telerik:RadGrid>


    Note the Unit Cost column.  Also, if a cell is a whole-dollar amount, there is no decimal at all, much less the ".00' that should be showing.

    I don't get why the InPlace Edit Mode can't assume the same styling as the ItemTemplate has.

  12. Veli
    Admin
    Veli avatar
    2002 posts

    Posted 20 Dec 2010 Link to this post

    Hello Jerry T.,

    Try setting AllowRounding="true":

    <telerik:GridNumericColumn DataField="fldCostPerUnit" HeaderText="Unit Cost" SortExpression="fldCostPerUnit" DataFormatString="{0:C2}" HeaderStyle-CssClass="radGridViewHeader" HeaderStyle-HorizontalAlign="Center" ItemStyle-HorizontalAlign="Right" HeaderStyle-Width="80px" UniqueName="fldCostPerUnit" DecimalDigits="2" NumericType="Currency" KeepNotRoundedValue="true" AllowRounding="true" />


    Veli
    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.
  13. Jerry T.
    Jerry T. avatar
    118 posts
    Member since:
    Jul 2012

    Posted 20 Dec 2010 Link to this post

    Thanks, Veli,

    That did it. Wouldn't have thought that attribute would have done that but thanks.

    Now...any way to get the text to be right-justified when editing?  :-)

    Jerry
  14. Jerry T.
    Jerry T. avatar
    118 posts
    Member since:
    Jul 2012

    Posted 20 Dec 2010 Link to this post

    Ok, another problem has reared its head.

    For any columns that are read-only (I don't want users to be able to edit the values), the number of decimals jump back to 4 digits:

    <telerik:GridNumericColumn DataField="fldUnitRev" HeaderText="Unit&nbsp;Rev" SortExpression="fldUnitRev" DataFormatString="{0:C2}" HeaderStyle-CssClass="radGridViewHeader" ItemStyle-HorizontalAlign="Right" HeaderStyle-Width="80px" UniqueName="fldUnitRev" ReadOnly="true" DecimalDigits="2" AllowRounding="true" NumericType="Currency" />

    I've tried various combinations of attributes and even went back to the GridBoundColumn but nothing works. I'd hate to have to end up using a GridTemplateColumn just to get two decimal places to show instead of four.

    Jerry
  15. Veli
    Admin
    Veli avatar
    2002 posts

    Posted 21 Dec 2010 Link to this post

    Yes, this is because the settings you specify for the number formatting are applied to RadNumericTextBox initialized when your column is editable. When you are using a read-only column, RadNumericTextBox is not initialized and is not used to format you data values.

    Nevertheless, we confirm an inconsistent behavior of the GridNumericColumn with respect to formatting of the data values in view mode and in edit mode when the column is read-only. I have notified our dev team of this issue and they will look into it on a first occasion. Please excuse us for the inconvenience. As a work-around, you need to programmatically find the value in the edit form and format it. You can use RadGrid's ItemDataBound event for that:

    protected void RadGrid1_ItemDataBound(object sender, GridItemEventArgs e)
    {
        if (e.Item is GridEditableItem && e.Item.IsInEditMode)
        {
            GridEditableItem editItem = (GridEditableItem)e.Item;
            double fldUnitRev = Double.Parse((editItem["fldUnitRev"].Controls[1] as Literal).Text);
            editItem["fldUnitRev"].Text = fldUnitRev.ToString("C2");
        }
    }

    Let me know how that works for you.

    Veli
    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.
  16. Jerry T.
    Jerry T. avatar
    118 posts
    Member since:
    Jul 2012

    Posted 21 Dec 2010 Link to this post

    Thanks, Veli.

    That workaround shows the proper format now. 

    But I have found yet another inconsistency (bug?)

    If a column is marked Read-Only in the markup, it cannot be changed in the codebehind (either in ItemCreated or ItemDatabound) but if it's NOT Read-Only in the markup, it CAN be changed to read-only in the codebehind in the ItemCreated event:

    <telerik:GridNumericColumn DataField="fldCost" HeaderText="Cost" SortExpression="fldCost" DataFormatString="{0:C2}" HeaderStyle-CssClass="radGridViewHeader" ItemStyle-HorizontalAlign="Right" HeaderStyle-Width="110px" UniqueName="fldCost" DecimalDigits="2" AllowRounding="true" KeepNotRoundedValue="true" NumericType="Currency" />

    Private Sub radgrdProgramServiceCostingSheet_ItemCreated(ByVal sender As Object, ByVal e As Telerik.Web.UI.GridItemEventArgs) Handles radgrdProgramServiceCostingSheet.ItemCreated
        If (TypeOf e.Item Is GridEditableItem) And e.Item.IsInEditMode Then
            Dim gei As GridEditableItem = DirectCast(e.Item, GridEditableItem)
            Dim numtxtRevenue As RadNumericTextBox = DirectCast(gei("fldRevenue").Controls(0), RadNumericTextBox)
            numtxtRevenue.Enabled = (gei("PricingOption").Text <> "1"'Not GP-based
            Dim numtxtCost As RadNumericTextBox = DirectCast(gei("fldCost").Controls(0), RadNumericTextBox)
            numtxtCost.ReadOnly = True
            'numtxtCost.Enabled = True
        End If
    End Sub


    We have a couple of columns in this grid that will need to be disabled/enabled based on various conditions that can change with the row itself being edited.  It appears if I set the column in the markup to NOT be read-only, then I can use the .Enabled = False/True in order to make it not editable/editable as a workaround, though.  But I cannot change the .ReadOnly property value if it is set to be ReadOnly="True" in the markup.
  17. Veli
    Admin
    Veli avatar
    2002 posts

    Posted 21 Dec 2010 Link to this post

    A column being ReadOnly is a different notion than a RadTextBox inside the column editor being ReadOnly. When the former is true, the column does not initialize RadTextBox at all! To manipulate RadTextBox, you need to keep the column editable (always having GridColumn.ReadOnly = false).

    Veli
    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.
  18. Jerry T.
    Jerry T. avatar
    118 posts
    Member since:
    Jul 2012

    Posted 21 Dec 2010 Link to this post

    Thanks, again.

    How can I get the text of a GridNumericColumn to be right-aligned?

    I tried this:
    http://www.telerik.com/community/forums/aspnet-ajax/grid/gridnumericcolumn-alignment.aspx

    and the text was right-aligned but it truncated the entire decimal portion and some to the left of the decimal.  I guess I'll have to play around with various padding values but that column type REALLY needs a right-align property. Most grids with numeric content are best formatted with right-aligned text.
  19. Veli
    Admin
    Veli avatar
    2002 posts

    Posted 22 Dec 2010 Link to this post

    You can programmatically set the HorizontalAlign properties of the various styles the RadNumericTextBox instance in your edited item exposes. If you were using a stand-alone RadNumericTextBox, you would have:

    <telerik:RadNumericTextBox ID="RadNumericTextBox1" runat="server" Type="Currency"
        EnabledStyle-HorizontalAlign="Right"
        HoveredStyle-HorizontalAlign="Right"
        DisabledStyle-HorizontalAlign="Right"
        EmptyMessageStyle-HorizontalAlign="Right"
        FocusedStyle-HorizontalAlign="Right"
        InvalidStyle-HorizontalAlign="Right"
        NegativeStyle-HorizontalAlign="Right"
        ReadOnlyStyle-HorizontalAlign="Right">
    </telerik:RadNumericTextBox>

    The above settings will have the numeric box right-align its cell text in all of the above states. With a numeric textbox in a grid column editor, you would need to use RadGrid's ItemDataBound event again to find RadNumericTextBox and set its properties programmatically:

    protected void RadGrid1_ItemDataBound(object sender, GridItemEventArgs e)
    {
        if (e.Item is GridEditableItem && e.Item.IsInEditMode)
        {
            GridEditableItem editItem = (GridEditableItem)e.Item;
            GridNumericColumnEditor numEditor = (GridNumericColumnEditor)editItem.EditManager.GetColumnEditor("Price");
            numEditor.NumericTextBox.EnabledStyle.HorizontalAlign = HorizontalAlign.Right;
            numEditor.NumericTextBox.DisabledStyle.HorizontalAlign = HorizontalAlign.Right;
            numEditor.NumericTextBox.HoveredStyle.HorizontalAlign = HorizontalAlign.Right;
            numEditor.NumericTextBox.EmptyMessageStyle.HorizontalAlign = HorizontalAlign.Right;
            numEditor.NumericTextBox.FocusedStyle.HorizontalAlign = HorizontalAlign.Right;
            numEditor.NumericTextBox.InvalidStyle.HorizontalAlign = HorizontalAlign.Right;
            numEditor.NumericTextBox.NegativeStyle.HorizontalAlign = HorizontalAlign.Right;
            numEditor.NumericTextBox.ReadOnlyStyle.HorizontalAlign = HorizontalAlign.Right;
        }
    }

    Now you get a completely right-aligned numeric textbox.

    Veli
    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.
  20. Jerry T.
    Jerry T. avatar
    118 posts
    Member since:
    Jul 2012

    Posted 22 Dec 2010 Link to this post

    Thanks, Veli.

    But, there should still be ONE attribute set in the markup for the GridNumericColumn that allows setting the value to be right-aligned in the regular grid and in edit mode. Adding 8 lines of code in the codebehind seems very inefficient.  It's great having all of those attributes available but they should only serve to customize something that would be an exception to an over-arching attribute setting.

    Also, when I use the HorizontalAlign property and set it to Right, when I go into edit mode, the value disappears in the cell.  I have to click on the cell before it appears.

    markup:
    <telerik:RadGrid ID="radgrdProgramServiceCostingSheet" runat="server" DataSourceID="odsGetServiceCostingSheet" EnableLinqExpressions="true" Width="100%"
        ShowStatusBar="true" AllowAutomaticUpdates="false"
        AutoGenerateColumns="false" AllowFilteringByColumn="false" AllowPaging="false" AllowSorting="true">
        <ClientSettings EnableRowHoverStyle="true" Selecting-AllowRowSelect="true" Scrolling-AllowScroll="true" Scrolling-ScrollHeight="280px" EnablePostBackOnRowClick="true" /> <%--ClientEvents-OnPopUpShowing="CostingSheetEditPopUpShowing" --%>
        <GroupingSettings CaseSensitive="false" />
        <MasterTableView TableLayout="Fixed" DataKeyNames="fldCostingSheetID,fldCostingSheetHeaderID,fldServiceVenueItemID,fldCostPerUnit,fldUnits,fldHours,fldGratuity,GP,fldTax,fldTaxable,PricingOption,BillType,fldPricingOptionID,fldBilltype,Category" EditMode="InPlace" > <%--EditFormSettings-PopUpSettings-Modal="true"--%>
            <HeaderStyle HorizontalAlign="Left" />
            <ItemStyle Wrap="false" />
            <AlternatingItemStyle Wrap="false" />
            <Columns>
                <telerik:GridEditCommandColumn ButtonType="LinkButton" HeaderStyle-CssClass="radGridViewHeader" HeaderStyle-Width="45px" EditText="" UpdateText="" CancelText="" UniqueName="EditButton" />
                <telerik:GridTemplateColumn DataField="Category" HeaderText="Cat" SortExpression="Category" HeaderStyle-CssClass="radGridViewHeader" HeaderStyle-Width="55px" UniqueName="Category" >
                    <ItemTemplate>
                        <%# String.Format("{0:c}", Eval("Category"))%>
                    </ItemTemplate>
                    <EditItemTemplate>
                        <telerik:RadComboBox ID="rcbCategory" runat="server" Width="55px" DropDownWidth="75px"
                            EnableEmptyListItem="false"
                            DataSourceId="odsGetCostingSheetCostCategories"
                            DataValueField="CostCatAbv"
                            DataTextField="CostCatAbv"
                            SelectedValue="<%# Bind('Category') %>">
                        </telerik:RadComboBox>  
                    </EditItemTemplate>
                </telerik:GridTemplateColumn>
                <telerik:GridBoundColumn DataField="VendorName" HeaderText="Vendor" SortExpression="VendorName" HeaderStyle-CssClass="radGridViewHeader" HeaderStyle-Width="135px" UniqueName="VendorName" />
                <telerik:GridBoundColumn DataField="fldCostingItem" HeaderText="Costing Item" SortExpression="fldCostingItem" HeaderStyle-CssClass="radGridViewHeader" HeaderStyle-Width="125px" UniqueName="fldCostingItem" />
                <telerik:GridNumericColumn DataField="fldCostPerUnit" HeaderText="Unit Cost" SortExpression="fldUnitRev" DataFormatString="{0:C2}" HeaderStyle-CssClass="radGridViewHeader" ItemStyle-HorizontalAlign="Right" HeaderStyle-Width="80px" UniqueName="fldCostPerUnit" DecimalDigits="2" AllowRounding="true" NumericType="Currency" />
                <telerik:GridNumericColumn DataField="fldHours" HeaderText="Hrs" SortExpression="fldHours" HeaderStyle-CssClass="radGridViewHeader" HeaderStyle-HorizontalAlign="Center" ItemStyle-HorizontalAlign="Right" HeaderStyle-Width="30px" UniqueName="fldHours" />
                <telerik:GridNumericColumn DataField="fldGratuity" HeaderText="Grat" SortExpression="fldGratuity" DataFormatString="{0:0%}" HeaderStyle-CssClass="radGridViewHeader" HeaderStyle-HorizontalAlign="Center" ItemStyle-HorizontalAlign="Right" HeaderStyle-Width="30px" UniqueName="fldGratuity" />
                <telerik:GridNumericColumn DataField="fldUnits" HeaderText="Units" SortExpression="fldUnits" HeaderStyle-CssClass="radGridViewHeader" HeaderStyle-HorizontalAlign="Center" ItemStyle-HorizontalAlign="Right" HeaderStyle-Width="30px" UniqueName="fldUnits" />
                <telerik:GridNumericColumn DataField="fldTax" HeaderText="Tax" SortExpression="fldTax" HeaderStyle-CssClass="radGridViewHeader" HeaderStyle-HorizontalAlign="Center" ItemStyle-HorizontalAlign="Right" HeaderStyle-Width="35px" UniqueName="fldTax" DecimalDigits="2" AllowRounding="true" KeepNotRoundedValue="true" />
                <telerik:GridCheckBoxColumn DataField="fldTaxable" HeaderText="Tax?" SortExpression="fldTaxable" HeaderStyle-CssClass="radGridViewHeader" HeaderStyle-Width="35px" UniqueName="fldTaxable" />
                <telerik:GridBoundColumn DataField="fldCost" HeaderText="Cost" SortExpression="fldCost" DataFormatString="{0:C2}" HeaderStyle-CssClass="radGridViewHeader" ItemStyle-HorizontalAlign="Right" HeaderStyle-Width="110px" UniqueName="fldCost" ReadOnly="true" />
                <telerik:GridNumericColumn DataField="GP" HeaderText="GP" SortExpression="GP" DataFormatString="{0:0%}" HeaderStyle-CssClass="radGridViewHeader" HeaderStyle-HorizontalAlign="Center" ItemStyle-HorizontalAlign="Right" HeaderStyle-Width="35px" UniqueName="GP" />
                <telerik:GridNumericColumn DataField="fldUnitRev" HeaderText="Unit Rev" SortExpression="fldUnitRev" DataFormatString="{0:C2}" HeaderStyle-CssClass="radGridViewHeader" ItemStyle-HorizontalAlign="Right" HeaderStyle-Width="80px" UniqueName="fldUnitRev" DecimalDigits="2" AllowRounding="true" KeepNotRoundedValue="true" NumericType="Currency" />
                <telerik:GridTemplateColumn DataField="PricingOption" HeaderText="Pricing Opt" SortExpression="PricingOption" HeaderStyle-CssClass="radGridViewHeader" HeaderStyle-Width="75px" UniqueName="PricingOption" >
                    <ItemTemplate>
                        <%# String.Format("{0:c}", Eval("PricingOption"))%>
                    </ItemTemplate>
                    <EditItemTemplate>
                        <telerik:RadComboBox ID="rcbPricingOption" runat="server" Width="75px" DropDownWidth="100px" Height="80px"
                            AutoPostBack="true"
                            EnableEmptyListItem="false"
                            DataSourceId="odsGetCostingSheetPricingOptions"
                            DataValueField="PricingOption"
                            DataTextField="PricingOption"
                            SelectedValue="<%# Bind('PricingOption') %>"
                            OnSelectedIndexChanged="rcbPricingOption_SelectedIndexChanged">
                        </telerik:RadComboBox>  
                    </EditItemTemplate>
                </telerik:GridTemplateColumn>
                <telerik:GridNumericColumn DataField="fldRevenue" HeaderText="Revenue" SortExpression="fldRevenue" DataFormatString="{0:C2}" HeaderStyle-CssClass="radGridViewHeader" HeaderStyle-HorizontalAlign="Center" ItemStyle-HorizontalAlign="Right" HeaderStyle-Width="110px" UniqueName="fldRevenue" DecimalDigits="2" AllowRounding="true" KeepNotRoundedValue="true" NumericType="Currency" />
                <telerik:GridNumericColumn DataField="fldRevPerPerson" HeaderText="Rev PP" SortExpression="fldRevPerPerson" DataFormatString="{0:C2}" HeaderStyle-CssClass="radGridViewHeader" HeaderStyle-HorizontalAlign="Center" ItemStyle-HorizontalAlign="Right" HeaderStyle-Width="95px" UniqueName="fldRevPerPerson" DecimalDigits="2" AllowRounding="true" KeepNotRoundedValue="true" NumericType="Currency" />
                <telerik:GridBoundColumn DataField="CommOption" HeaderText="Comm" SortExpression="CommOption" HeaderStyle-CssClass="radGridViewHeader" HeaderStyle-Width="80px" UniqueName="CommOption" />
                <telerik:GridBoundColumn DataField="BillType" HeaderText="Bill Type" SortExpression="BillType" HeaderStyle-CssClass="radGridViewHeader" HeaderStyle-Width="80px" UniqueName="BillType" />
                <telerik:GridBoundColumn DataField="fldGroupType" HeaderText="Group" SortExpression="fldGroupType" HeaderStyle-CssClass="radGridViewHeader" HeaderStyle-Width="50px" ItemStyle-HorizontalAlign="Right" UniqueName="fldGroupType" />
                <telerik:GridBoundColumn DataField="fldSortOrder" HeaderText="Sort" SortExpression="fldSortOrder" HeaderStyle-CssClass="radGridViewHeader" HeaderStyle-Width="40px" ItemStyle-HorizontalAlign="Right" UniqueName="fldSortOrder" />
                <telerik:GridBoundColumn DataField="fldTax1" UniqueName="fldTax1" Visible="false" ReadOnly="true" />
                <telerik:GridBoundColumn DataField="fldTax2" UniqueName="fldTax2" Visible="false" ReadOnly="true" />
            </Columns>
        </MasterTableView>
    </telerik:RadGrid>

    codebehind:
    Private Sub radgrdProgramServiceCostingSheet_ItemDataBound(ByVal sender As Object, ByVal e As Telerik.Web.UI.GridItemEventArgs) Handles radgrdProgramServiceCostingSheet.ItemDataBound
        If (TypeOf e.Item Is GridDataItem) Then
        *bunch of unrelated stuff snipped*
            If (TypeOf e.Item Is GridEditableItem) And e.Item.IsInEditMode Then
                Dim gei As GridEditableItem = DirectCast(e.Item, GridEditableItem)
                Dim numtxtGP As RadNumericTextBox = DirectCast(gei("GP").Controls(0), RadNumericTextBox)
                Dim numtxtUnitRev As RadNumericTextBox = DirectCast(gei("fldUnitRev").Controls(0), RadNumericTextBox)
                Dim numtxtRevenue As RadNumericTextBox = DirectCast(gei("fldRevenue").Controls(0), RadNumericTextBox)
                Dim rcbPricingOpt As RadComboBox = DirectCast(gei("PricingOption").FindControl("rcbPricingOption"), RadComboBox)
                numtxtUnitRev.DisabledStyle.HorizontalAlign = HorizontalAlign.Right
                numtxtUnitRev.EmptyMessageStyle.HorizontalAlign = HorizontalAlign.Right
                numtxtUnitRev.EnabledStyle.HorizontalAlign = HorizontalAlign.Right
                numtxtUnitRev.FocusedStyle.HorizontalAlign = HorizontalAlign.Right
                numtxtUnitRev.HoveredStyle.HorizontalAlign = HorizontalAlign.Right
                numtxtUnitRev.InvalidStyle.HorizontalAlign = HorizontalAlign.Right
                numtxtUnitRev.ReadOnlyStyle.HorizontalAlign = HorizontalAlign.Right
            End If
        End If
    End Sub
  21. Veli
    Admin
    Veli avatar
    2002 posts

    Posted 22 Dec 2010 Link to this post

    Have you tried with the latest version of Telerik RadControls? This is issue may already have been fixed.

    Veli
    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.
  22. Jerry T.
    Jerry T. avatar
    118 posts
    Member since:
    Jul 2012

    Posted 22 Dec 2010 Link to this post

    Veli,

    We are using Q3 2010 SP1 (2010.3.1215.40)

    Jerry
  23. Jerry T.
    Jerry T. avatar
    118 posts
    Member since:
    Jul 2012

    Posted 22 Dec 2010 Link to this post

    What's interesting is that I took off the right align off for the Enabled style.  I left the Hover style as Right align and when I hover over the field in edit mode, the value disappears until I hover off or click in the field.
    numtxtUnitRev.EnabledStyle.HorizontalAlign = HorizontalAlign.Right





  24. Veli
    Admin
    Veli avatar
    2002 posts

    Posted 23 Dec 2010 Link to this post

    I am consistently unable to reproduce this issue with the version you have indicated. Attaching a test page. Can you try to reproduce this issue in it?

    Veli
    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.
  25. Jerry T.
    Jerry T. avatar
    118 posts
    Member since:
    Jul 2012

    Posted 23 Dec 2010 Link to this post

    That test worked perfect for me. I tried breaking it by adding in all of the CSS that we use and various web.config/cdn settings and I can't break it.

    I finally decided to try the developer tool in IE and using the "Select element" tool, I managed to discover that the data isn't really disappearing.  The Input element is just too wide and is being covered by the dropdown next to it. I should be able to correct that via CSS or, if necessary, some codebehind adjustments.

    Thanks for all of your help, Veli.


    Jerry
  26. Jerry T.
    Jerry T. avatar
    118 posts
    Member since:
    Jul 2012

    Posted 23 Dec 2010 Link to this post

    Ok...in the long run, this is what works for me:
    If (TypeOf e.Item Is GridEditableItem) And e.Item.IsInEditMode Then
        Dim gei As GridEditableItem = DirectCast(e.Item, GridEditableItem)
        Dim numtxtUnitCost As RadNumericTextBox = DirectCast(gei("fldCostPerUnit").Controls(0), RadNumericTextBox)
        Dim numtxtGP As RadNumericTextBox = DirectCast(gei("GP").Controls(0), RadNumericTextBox)
        Dim numtxtUnitRev As RadNumericTextBox = DirectCast(gei("fldUnitRev").Controls(0), RadNumericTextBox)
        Dim numtxtRevenue As RadNumericTextBox = DirectCast(gei("fldRevenue").Controls(0), RadNumericTextBox)
        Dim rcbPricingOpt As RadComboBox = DirectCast(gei("PricingOption").FindControl("rcbPricingOption"), RadComboBox)
        numtxtUnitCost.Width = 80
        numtxtUnitCost.NumberFormat.DecimalDigits = 2
        numtxtUnitCost.NumberFormat.KeepNotRoundedValue = True
        numtxtUnitCost.NumberFormat.KeepTrailingZerosOnFocus = True
        numtxtUnitCost.NumberFormat.AllowRounding = True
        numtxtUnitCost.DisabledStyle.HorizontalAlign = HorizontalAlign.Right
        numtxtUnitCost.EnabledStyle.HorizontalAlign = HorizontalAlign.Right
        numtxtUnitRev.Width = 80
        numtxtUnitRev.NumberFormat.DecimalDigits = 2
        numtxtUnitRev.NumberFormat.KeepNotRoundedValue = True
        numtxtUnitRev.NumberFormat.KeepTrailingZerosOnFocus = True
        numtxtUnitRev.NumberFormat.AllowRounding = True
        numtxtUnitRev.DisabledStyle.HorizontalAlign = HorizontalAlign.Right
        numtxtUnitRev.EnabledStyle.HorizontalAlign = HorizontalAlign.Right

    and all of that code is just to be sure that two columns have the same formatting that I specified in the markup for the RadGrid for those columns.  I have 3 other columns yet to do the same for.

    We *really* need that formatting to pass through to edit mode as a default instead of having to write all that unnecessary code on the server side.

    Thanks.
  27. Marc Schaaks
    Marc Schaaks avatar
    16 posts
    Member since:
    May 2010

    Posted 27 Jan 2011 Link to this post

    Veli, has the decimaldigits feature been added to the grid ? I am currently running version 2010.3.1109.35.

    thx,

    Marc.
  28. Sebastian
    Admin
    Sebastian avatar
    9934 posts

    Posted 27 Jan 2011 Link to this post

    Hi Marc,

    we added a property to set the decimal digits for GridNumericColumn since version Q3 2010 SP1 (2010.3.1215) of the controls. Consider migrating either to this or the latest 2010.3.1317 release of the suite (follow these steps to do so) to take advantage of it.

    Best regards,
    Sebastian
    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.
  29. Jerry T.
    Jerry T. avatar
    118 posts
    Member since:
    Jul 2012

    Posted 06 May 2011 Link to this post

    Alright, something broke!

    We're using the latest build (2011.1.413.40) and the code I had working from my post in December is no longer working:
    http://www.telerik.com/community/forums/aspnet-ajax/grid/gridnumericcolumn-with-decimal-digits-when-edit.aspx#1468048

    I can't get the GridNumericColumn values to be right-aligned when in edit mode (InPlace).

    thoughts?

    Jerry
  30. Veli
    Admin
    Veli avatar
    2002 posts

    Posted 09 May 2011 Link to this post

    Hi Jerry T.,

    I tested the code you are using with the latest version of the controls and it seems to be working OK. Attaching a screen shot. Can you give us more info on your scenario? Some sample code would be helpfull too.

    Veli
    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.

  31. Jerry T.
    Jerry T. avatar
    118 posts
    Member since:
    Jul 2012

    Posted 09 May 2011 Link to this post

    I ended up setting the .CssClass in the codebehind to a basic CSS style that sets text-align: right!important and that seemed to do the trick.
Back to Top
UI for ASP.NET Ajax is Ready for VS 2017