This is a migrated thread and some comments may be shown as answers.

GridNumericColumn Text aling

4 Answers 111 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Jouni
Top achievements
Rank 1
Jouni asked on 11 Feb 2009, 08:53 AM
Hello

How can I aling  numbers to the rightside of box ?

4 Answers, 1 is accepted

Sort by
0
Princy
Top achievements
Rank 2
answered on 11 Feb 2009, 09:44 AM
Hi Jouni,

I suppose you want to align the value of RadNumericTextBox for a GridNumericColumn when its in EditMode. If that is the case, you can try out the following code snippets.

CS:
protected void RadGrid1_ItemDataBound(object sender, GridItemEventArgs e)  
{  
    if (e.Item is GridEditableItem && e.Item.IsInEditMode)  
    {  
        GridEditableItem item = (GridEditableItem)e.Item;  
        RadNumericTextBox txtbx = (RadNumericTextBox)item["EmployeeID"].Controls[0];  
        txtbx.CssClass = "numericText";              
    }          

CSS:
<style type="text/css">  
.numericText  
{  
    direction:rtl;  
}  
</style>  

Thanks,
Princy.
0
Daniel
Telerik team
answered on 11 Feb 2009, 02:47 PM
Hello Jouni,

I have another suggestion:

cs
protected void RadGrid1_ItemCreated(object sender, GridItemEventArgs e) 
    if (e.Item is GridEditableItem && e.Item.IsInEditMode) 
    { 
        GridEditableItem item = (GridEditableItem)e.Item; 
        GridNumericColumnEditor editor = (GridNumericColumnEditor)item.EditManager.GetColumnEditor("myNumericColumn"); 
        editor.NumericTextBox.EnabledStyle.HorizontalAlign = HorizontalAlign.Right;  
    } 

<telerik:GridNumericColumn DataField="ID" UniqueName="myNumericColumn"
    <ItemStyle HorizontalAlign="Right" /> 
</telerik:GridNumericColumn> 

Let us know whether these directions are helpful.

Best regards,
Daniel
the Telerik team

Check out Telerik Trainer, the state of the art learning tool for Telerik products.
0
Hossein
Top achievements
Rank 1
Iron
answered on 22 Sep 2012, 04:16 PM
Hi Jouni,
I got the same issue but when I used your solution. It works fine except on initial load it shows all number on left side and as soon as I hover the mouse on top of text boxes in grid column it shift them to right side. If I refresh the page it will put the number again on left side.
Is there anyway to make the RadNumericColumn to display the  numbers on right on initial radgrid load?

Regards
Hossein
0
Vasil
Telerik team
answered on 27 Sep 2012, 06:49 AM
Hello Hossein,

A bit old thread, the solution that Daniel has give was working for the browsers back in 2009.
However in IE9 there is a browser bug. It does not refreshes the layout when updating some properties like text-align. Generally the RadInput has multiple styles depending on its state (enabled/disabled/hovered, etc.) So it serializes the styles and applies them client side with JavaScript.
And here it is coming the bug of IE: when some styles are changed with JavaScript they are not correctly updated, until other styles like width or position are changed as well (causing layout repaint).

You can workaround this by styling your inputs with CSS. This way the styles will be applied. Check these forum threads for an examples:
http://www.telerik.com/community/forums/aspnet-ajax/input/radnumerictextbox-align-right.aspx
http://www.telerik.com/community/forums/aspnet-ajax/input/radnumerictextbox-horizontalalign-not-work.aspx

Kind regards,
Vasil
the Telerik team
If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the RadControls for ASP.NET AJAX, subscribe to their blog feed now.
Tags
Grid
Asked by
Jouni
Top achievements
Rank 1
Answers by
Princy
Top achievements
Rank 2
Daniel
Telerik team
Hossein
Top achievements
Rank 1
Iron
Vasil
Telerik team
Share this question
or