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

HorizontalAlign="Right" not working

2 Answers 340 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Roland
Top achievements
Rank 1
Roland asked on 05 Mar 2009, 12:27 PM

Hi!

I have a grid where price and quantity information shuold be displayed, unfortunately i cannot set die text alignment to right.

Here is my grid declaration

<telerik:RadGrid ID = "SummaryGrid" runat="server" AllowSorting="true" AutoGenerateColumns="false" style="margin: 0 0 0px 20px;" 
                                         Width="760px" Height="300px" GridLines="none" OnNeedDataSource="SummaryGridNeedsData" Skin="Default"
                            <MasterTableView GroupLoadMode="Client" UseAllDataFields="true"

And a column in which the alignment is not working

 <telerik:GridBoundColumn SortExpression="Quantity" HeaderText="Quantity" HeaderStyle-HorizontalAlign="Center" ItemStyle-HorizontalAlign="Right"  HeaderButtonType="TextButton" DataField="Quantity"
                                    <ItemStyle Width="80px" HorizontalAlign="Right"/> 
                                </telerik:GridBoundColumn> 

I tried to add the Horizontal Align attribute in both tags(GridboundColumn and ItemStyle) also i tried to set in only in one of these two tags, it never worked.

Can you please help me to solve this little issue.

Greetings
Martin


2 Answers, 1 is accepted

Sort by
0
Dimo
Telerik team
answered on 05 Mar 2009, 01:29 PM
Hello Martin,

The code should work, please make sure that there are no other settings (e.g. in ASP.NET themes) or CSS styles in the web application, which could override the RadGrid settings.

By the way, Width should be set to HeaderStyle, not ItemStyle.

Here is a page that works as expected:

<%@ Page Language="C#" %> 
<%@ Import Namespace="System.Data" %> 
<%@ Register Assembly="Telerik.Web.UI" Namespace="Telerik.Web.UI" TagPrefix="telerik" %> 
 
<script runat="server"
 
    protected void RadGrid_NeedDataSource(object sender, GridNeedDataSourceEventArgs e) 
    { 
        DataTable dt = new DataTable(); 
        DataRow dr; 
        int colsNum = 2
        int rowsNum = 10
        string colName = "Column"
 
        for (int j = 1; j <= colsNum; j++) 
        { 
            dt.Columns.Add(String.Format("{0}{1}", colName, j)); 
        } 
 
        for (int i = 1; i <= rowsNum; i++) 
        { 
            dr = dt.NewRow(); 
 
            for (int k = 1; k <= colsNum; k++) 
            { 
                dr[String.Format("{0}{1}", colName, k)] = String.Format("{0}{1} Row{2}", colName, k, i); 
            } 
            dt.Rows.Add(dr); 
        } 
 
        (sender as RadGrid).DataSource = dt
    } 
     
</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 runat="server"
<meta http-equiv="content-type" content="text/html; charset=utf-8" /> 
<title>RadControls for ASP.NET AJAX</title> 
</head> 
<body> 
<form id="form1" runat="server"
<asp:ScriptManager ID="ScriptManager1" runat="server" /> 
 
<telerik:RadGrid 
    ID="RadGrid1" 
    runat="server" 
    width="600px" 
    AutoGenerateColumns="false" 
    OnNeedDataSource="RadGrid_NeedDataSource"
    <MasterTableView> 
        <Columns> 
            <telerik:GridBoundColumn HeaderText="Right" DataField="Column1"
                <HeaderStyle HorizontalAlign="Right" /> 
                <ItemStyle HorizontalAlign="Right" /> 
            </telerik:GridBoundColumn> 
            <telerik:GridBoundColumn HeaderText="Left" DataField="Column2" /> 
        </Columns> 
    </MasterTableView> 
</telerik:RadGrid> 
 
</form> 
</body> 
</html> 
 


All the best,
Dimo
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.
0
Roland
Top achievements
Rank 1
answered on 09 Mar 2009, 07:16 AM
Hi!

Thanks for your fast reply, the problem was caused by my css settings.

Regards,
Martin
Tags
Grid
Asked by
Roland
Top achievements
Rank 1
Answers by
Dimo
Telerik team
Roland
Top achievements
Rank 1
Share this question
or