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

Individual Column Properties

6 Answers 101 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Philip
Top achievements
Rank 1
Philip asked on 09 Jul 2008, 07:50 PM
I have created a RadGrid with a child (details) grid expansion. All of the data is loading correctly, but I am having trouble accession the collection property for the details grid.

I would like to left justify two columns, while centering the rest.
 
If I go into the "Open Property Builder" section, choose the Details grid heirarchy object, tableview settings, and the toggle property grid functions, I get the properties for the details grid. If I scroll down to the "DetailsTables" section and choose the box with the three periods in it, it gives me the following error:

"Object reference not set to an instance of an object"

How can I obtain the properties for the individual columns in the details grid?

6 Answers, 1 is accepted

Sort by
0
Princy
Top achievements
Rank 1
answered on 10 Jul 2008, 08:00 AM
Hello Philip,

I have a suggestion.You can align the columns in the aspx side as shown in the code snippet below.

<DetailTables> 
    <telerik:GridTableView Name="Detail1" DataSourceID="SqlDataSource3"
         <Columns> 
              <telerik:GridBoundColumn ItemStyle-HorizontalAlign="Left" DataField="FirstName" HeaderText="FirstName" UniqueName="FirstName" ></telerik:GridBoundColumn> 
              <telerik:GridBoundColumn ItemStyle-HorizontalAlign="Right" DataField="ToandFro" HeaderText="ToandFro" UniqueName="ToandFro"  ></telerik:GridBoundColumn> 
              <telerik:GridBoundColumn ItemStyle-HorizontalAlign="Center" DataField="TicketsSold" HeaderText="TicketsSold" UniqueName="TicketsSold"  ></telerik:GridBoundColumn>                   
          </Columns> 
     </telerik:GridTableView> 
</DetailTables> 

Thanks
Princy.
0
Philip
Top achievements
Rank 1
answered on 10 Jul 2008, 12:39 PM
Thanks for the reply. I am new to Telerik, so forgive me if my questions are not to the expertise of others.

I looked at your suggestion, and I can not find the details grid in the aspx. The code from my project is listed below.

I see the bound properties for the master grid, but not the details grid.

<title>Untitled Page</title>

</

head>

<

body background="cementbase.jpg">

<form id="form1" runat="server">

<div>

<br />

<br />

<telerik:radscriptmanager id="RadScriptManager1" runat="server"></telerik:radscriptmanager>

<br />

<br />

&nbsp;</div>

<asp:SqlDataSource ID="SqlDataSource1" runat="server" ConnectionString="<%$ ConnectionStrings:FSRConnectionString %>"

SelectCommand="SELECT [OrderNumber], [Name], [created], [Liability], [ReservationStatusMessage] FROM [GunOrders]">

</asp:SqlDataSource>

<asp:SqlDataSource ID="SqlDataSource2" runat="server" ConnectionString="<%$ ConnectionStrings:FSRConnectionString %>"

SelectCommand="SELECT OrderNumber AS [Order Number], LineItem AS [Line Item], UniqueNumber AS [Unique #], DRAWING AS [Drawing #], DESCRIPTION, Quantity, OrderDate, ShippedText AS [Shipping Status], Status, RejectText, QuantityShipped, QuantityBO FROM Orders WHERE (OrderNumber = @OrderNumber)">

<SelectParameters>

<asp:Parameter Name="OrderNumber" Type="String" />

</SelectParameters>

</asp:SqlDataSource>

<telerik:radgrid id="RadGrid1" runat="server" datasourceid="SqlDataSource1" gridlines="None" Skin="Office2007" BackColor="#BBBEB3">

<

MasterTableView DataSourceID="SqlDataSource1" AutoGenerateColumns="False" DataKeyNames="OrderNumber" HorizontalAlign="Center"><DetailTables>

<

telerik:GridTableView runat="server" DataKeyNames="Order Number" DataSourceID="SqlDataSource2" HorizontalAlign="Center" SkinID="Office2007" BackColor="#D3DBE9" CellPadding="4" CellSpacing="4" BorderColor="Black" BorderStyle="Solid"><ParentTableRelation>

<

telerik:GridRelationFields MasterKeyField="OrderNumber" DetailKeyField="OrderNumber"></telerik:GridRelationFields>

</

ParentTableRelation>

<

RowIndicatorColumn Visible="False">

<

HeaderStyle Width="20px"></HeaderStyle>

</

RowIndicatorColumn>

<

ExpandCollapseColumn Visible="False" Resizable="False">

<

HeaderStyle Width="20px"></HeaderStyle>

</

ExpandCollapseColumn>

<

EditFormSettings>

<

PopUpSettings ScrollBars="None"></PopUpSettings>

</

EditFormSettings>

<ItemStyle HorizontalAlign="Left" VerticalAlign="Middle" BorderColor="Black" BorderStyle="Solid" />

<HeaderStyle HorizontalAlign="Left" VerticalAlign="Middle" />

<AlternatingItemStyle HorizontalAlign="Left" VerticalAlign="Middle" />

<EditItemStyle HorizontalAlign="Left" VerticalAlign="Middle" BorderColor="#FAFAFA" BorderStyle="Solid" />

</

telerik:GridTableView>

</

DetailTables>

<

RowIndicatorColumn Visible="False">

<

HeaderStyle Width="20px"></HeaderStyle>

</

RowIndicatorColumn>

<

ExpandCollapseColumn Resizable="False">

<

HeaderStyle Width="20px"></HeaderStyle>

</

ExpandCollapseColumn>

<

Columns>

<

telerik:GridBoundColumn DataField="OrderNumber" HeaderText="Order Number" SortExpression="OrderNumber" UniqueName="OrderNumber"></telerik:GridBoundColumn>

<

telerik:GridBoundColumn DataField="Name" HeaderText="Requested By" SortExpression="Name" UniqueName="Name"></telerik:GridBoundColumn>

<

telerik:GridBoundColumn DataField="created" HeaderText="created" SortExpression="created" UniqueName="created" DataType="System.DateTime"></telerik:GridBoundColumn>

<

telerik:GridBoundColumn DataField="Liability" HeaderText="Initial Liability" SortExpression="Liability" UniqueName="Liability"></telerik:GridBoundColumn>

<

telerik:GridBoundColumn DataField="ReservationStatusMessage" HeaderText="IR Status" SortExpression="ReservationStatusMessage" UniqueName="ReservationStatusMessage"></telerik:GridBoundColumn>

</

Columns>

<

EditFormSettings>

<

PopUpSettings ScrollBars="None"></PopUpSettings>

</

EditFormSettings>

<ItemStyle HorizontalAlign="Center" VerticalAlign="Middle" />

<HeaderStyle HorizontalAlign="Center" VerticalAlign="Middle" />

</

MasterTableView>

<AlternatingItemStyle HorizontalAlign="Center" VerticalAlign="Middle" />

<ItemStyle HorizontalAlign="Center" VerticalAlign="Middle" />

<HeaderStyle HorizontalAlign="Center" VerticalAlign="Bottom" />

<ActiveItemStyle HorizontalAlign="Center" VerticalAlign="Middle" />

</

telerik:radgrid>

</form>

</

body>

</

html>

0
Princy
Top achievements
Rank 1
answered on 11 Jul 2008, 06:37 AM
Hi Philip,

I think you are trying to achieve the column alignment for the MasterTable since I cannot find any column collection in the Detail table. If that is the case, you can try setting the ItemStyle property as shown in the code snippet below.

ASPX:
<Columns> 
   <telerik:GridBoundColumn DataField="OrderNumber" ItemStyle-HorizontalAlign="Left"  HeaderText="Order Number" SortExpression="OrderNumber" UniqueName="OrderNumber"></telerik:GridBoundColumn> 
 
   <telerik:GridBoundColumn DataField="Name" ItemStyle-HorizontalAlign="Left" HeaderText="Requested By" SortExpression="Name" UniqueName="Name"></telerik:GridBoundColumn> 
 
   <telerik:GridBoundColumn DataField="created" ItemStyle-HorizontalAlign="Center" HeaderText="created" SortExpression="created" UniqueName="created" DataType="System.DateTime"></telerik:GridBoundColumn> 
 
   <telerik:GridBoundColumn DataField="Liability" ItemStyle-HorizontalAlign="Center" HeaderText="Initial Liability" SortExpression="Liability" UniqueName="Liability"></telerik:GridBoundColumn> 
 
   <telerik:GridBoundColumn DataField="ReservationStatusMessage" ItemStyle-HorizontalAlign="Center" HeaderText="IR Status" SortExpression="ReservationStatusMessage" UniqueName="ReservationStatusMessage"></telerik:GridBoundColumn> 
</Columns> 

Thanks
Princy.

0
Philip
Top achievements
Rank 1
answered on 14 Jul 2008, 11:54 AM
Thanks for your help. I figured out what the problem was. I dug a little deeper into the details table properties and found that the autogenerate columns was selected. I turned that off and was then able to control the grid through the ASPX source side.
0
Princy
Top achievements
Rank 1
answered on 14 Jul 2008, 12:25 PM
Hi Philip,

You can also try the following code snippet to handle the autogenerated column in the ColumnCreated event.

CS:
 protected void RadGrid1_ColumnCreated(object sender, GridColumnCreatedEventArgs e)  
    {  
        GridBoundColumn col = (GridBoundColumn)e.Column;  
        if (col.UniqueName == "ColUniqueName")  
        {  
            col.ItemStyle.HorizontalAlign = HorizontalAlign.Left;  
            col.HeaderStyle.HorizontalAlign = HorizontalAlign.Left;  
        }  
    } 


Thanks
Princy.
0
Philip
Top achievements
Rank 1
answered on 14 Jul 2008, 12:28 PM
Wow, thanks for that. I didnt know it could be addressed in that manner. Thanks again for your help.
Tags
Grid
Asked by
Philip
Top achievements
Rank 1
Answers by
Princy
Top achievements
Rank 1
Philip
Top achievements
Rank 1
Share this question
or