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

[Solved] Column alignment to the left

4 Answers 270 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Sk
Top achievements
Rank 1
Sk asked on 18 May 2013, 06:01 AM
Hi,

I have in rad grid auto generate columns are true and i have numeric values in columns. Is there any event of rad grid or there is any other method that the numeric values should be right aligned and the string values should be left aligned?

<telerik:RadGrid ID="gvRADInvoiceDetail" runat="server" AllowPaging="true" PageSize="25"
                                GridLines="Both" AllowSorting="true" BorderStyle="None" OnNeedDataSource="gvRADInvoiceDetail_NeedDataSource">
                                <ClientSettings>
                                    <Scrolling AllowScroll="True" UseStaticHeaders="true" SaveScrollPosition="true">
                                    </Scrolling>
                                </ClientSettings>
                                <MasterTableView AutoGenerateColumns="true">
                                    <PagerStyle Mode="NextPrevAndNumeric" PageSizeLabelText="Records Per Page :" PageSizes="{25, 50, 100, 200,250}" />
                                    <NoRecordsTemplate>
                                        <div class="search-noresults-container">
                                            <div class="inner-content">
                                                <p>
                                                    <strong>No Results Found</strong></p>
                                                <p class="small-text">
                                                    Please verify the search criteria and try again</p>
                                            </div>
                                    </NoRecordsTemplate>
                                </MasterTableView>
                            </telerik:RadGrid>

Please suggest.....

Thanks,

4 Answers, 1 is accepted

Sort by
0
Jayesh Goyani
Top achievements
Rank 2
answered on 18 May 2013, 04:09 PM
Hello,

protected void RadGrid1_NeedDataSource(object sender, GridNeedDataSourceEventArgs e)
        {
            dynamic data = new[] {
              new { ID = 1, Name ="aaa"},
              new { ID = 2, Name = "bbb"},
              new { ID = 3, Name = "ccc"},
              new { ID = 4, Name = "ddd"},
              new { ID = 5, Name ="eee"},
              new { ID = 6, Name ="aaa"},
              new { ID = 7, Name = "bbb"},
              new { ID = 8, Name = "ccc"},
              new { ID = 9, Name = "ddd"},
              new { ID = 10, Name ="eee"}
            };
            RadGrid1.DataSource = data;
 
 
        }
 
 
 protected void RadGrid1_ColumnCreated(object sender, GridColumnCreatedEventArgs e)
        {
            if (e.Column.UniqueName == "ID")
            {
                e.Column.ItemStyle.HorizontalAlign = HorizontalAlign.Right;
                e.Column.HeaderStyle.HorizontalAlign = HorizontalAlign.Right;
            }
        }


Thanks,
Jayesh Goyani
0
Sk
Top achievements
Rank 1
answered on 20 May 2013, 12:54 PM
Hiii,

Thank you for your reply.
 I have one query that in the need data source we have need to add all the columns returns from SP or only those to which we want to right align???

0
Jayesh Goyani
Top achievements
Rank 2
answered on 20 May 2013, 01:44 PM
Hello,

For Example by using below condition you can apply right align to only ID column.

e.Column.UniqueName == "ID"

If you do not add above condition then it applied to all column.

Thanks,
Jayesh Goyani
0
Sk
Top achievements
Rank 1
answered on 24 May 2013, 06:01 AM
Thank you  Jayesh Goyani.......................
Tags
Grid
Asked by
Sk
Top achievements
Rank 1
Answers by
Jayesh Goyani
Top achievements
Rank 2
Sk
Top achievements
Rank 1
Share this question
or