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
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.
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 />
</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>
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.
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.