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

[Solved] In Place Edit TextBox alignment

3 Answers 243 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Christopher Borys
Top achievements
Rank 1
Christopher Borys asked on 07 Dec 2009, 02:06 AM
My numeric columns are right aligned.  In the edit mode (in place) I get a TextBox input that is left aligned.  I would like to have the text box that is right aligned e.g. numeric text is right justified within edit box.  Is this possible? Anybody know how? 

Chris

3 Answers, 1 is accepted

Sort by
0
Princy
Top achievements
Rank 2
answered on 07 Dec 2009, 05:51 AM
Hello Christopher,

Check out the following example which should right align the text in the RadNumericTextBox for a NumericColumn when in EditMode:
aspx:
<telerik:GridNumericColumn HeaderText="Numeric Column" DataField="Number" DataType="System.Int32" UniqueName="NumericColumn"
     <ItemStyle HorizontalAlign="Right"/>    
</telerik:GridNumericColumn> 

c#:
 protected void RadGrid1_ItemDataBound(object sender, Telerik.Web.UI.GridItemEventArgs e) 
    { 
       if (e.Item is GridEditableItem && e.Item.IsInEditMode) 
        { 
            GridEditableItem dataItem = (GridEditableItem)e.Item; 
            RadNumericTextBox rdnmrctxtbx = (RadNumericTextBox)dataItem["NumericColumn"].Controls[0];             
            rdnmrctxtbx.Style.Add("text-align""right"); 
             
        } 
    } 

Thanks
Princy.
0
Christopher Borys
Top achievements
Rank 1
answered on 08 Dec 2009, 03:02 AM
Even after using this code, when I switch from View to Edit mode, initially the cell is left aligned.  The cell gets right aligned when I click on it.  This is even more awkward.  I guess there is still something more that can be set but I have no clue what?
0
Princy
Top achievements
Rank 2
answered on 08 Dec 2009, 06:58 AM
Hi Christopher,

Can you try setting the following css style and see if it makes a difference:
c#:
protected void RadGrid1_ItemDataBound(object sender, Telerik.Web.UI.GridItemEventArgs e) 
    { 
        if (e.Item is GridEditableItem && e.Item.IsInEditMode) 
        { 
            GridEditableItem dataItem = (GridEditableItem)e.Item; 
            RadNumericTextBox rdnmrctxtbx = (RadNumericTextBox)dataItem["NumericColumn"].Controls[0]; 
            rdnmrctxtbx.CssClass = "myclass";             
        } 
    } 

css:
 .myclass 
    { 
      text-align:rightright !important; 
    } 

Thanks
Princy.
Tags
Grid
Asked by
Christopher Borys
Top achievements
Rank 1
Answers by
Princy
Top achievements
Rank 2
Christopher Borys
Top achievements
Rank 1
Share this question
or