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

[Solved] Best way to handle Details View?

4 Answers 223 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Robert
Top achievements
Rank 1
Robert asked on 21 May 2008, 08:51 PM
Simple:  I have a Companies table with 30 fields.  I just want my grid to show like 4 of them then when I select the row I want the rest of the details to appear.  I also would like them to be able to edit, insert and delete from this "details" view.

Questions...

1. How can I do this exactly?

2. Also, do I need 2 datasources (1 for the grid and 1 for the details view of the selected company ?)

3. Also, how do I customize the field layout the way I want it?

The online examples dont seem to help much.

4 Answers, 1 is accepted

Sort by
0
Shinu
Top achievements
Rank 2
answered on 22 May 2008, 05:51 AM
Hi Robert,

Try using RadGrid Hierarchy to achieve this. You  can use a single DataSource for  both MasterTable and the Detail table.Show the required four fields in the MasterTable and rest of the fields in the Detail table.

ASPX:
<asp:SqlDataSource ID="SqlDataSource1" runat="server" ConnectionString="<%$ ConnectionStrings:NorthwindConnectionString %>" 
                SelectCommand="SELECT [ProductID], [ProductName], [SupplierID], [CategoryID], [QuantityPerUnit], [UnitPrice], [UnitsInStock], [UnitsOnOrder], [ReorderLevel], [Discontinued] FROM [Products]"
            </asp:SqlDataSource> 
 
 
 <telerik:RadGrid ID="RadGrid1"     runat="server"  AllowPaging="True" PageSize="3"   
                AutoGenerateColumns="False" DataSourceID="SqlDataSource1" > 
                 
                <MasterTableView    DataSourceID="SqlDataSource1"
                   
                    <Columns> 
                        
                        <telerik:GridBoundColumn DataField="ProductName"    Aggregate="Count" HeaderText="ProductName" SortExpression="ProductName" 
                            UniqueName="ProductName"
                            <HeaderStyle Wrap="True"  /> 
                        </telerik:GridBoundColumn> 
                        
                        <telerik:GridBoundColumn Aggregate="Count" DataField="ProductID"  DataType="System.Int32" HeaderText="ProductID" 
                          SortExpression="ProductID" UniqueName="ProductID"
                        </telerik:GridBoundColumn> 
                        <telerik:GridBoundColumn DataField="SupplierID" DataType="System.Int32" HeaderText="SupplierID" 
                            SortExpression="SupplierID" UniqueName="SupplierID" > 
                        </telerik:GridBoundColumn> 
                        <telerik:GridBoundColumn DataField="CategoryID" DataType="System.Int32" HeaderText="CategoryID" 
                            SortExpression="CategoryID" UniqueName="CategoryID"
                          </telerik:GridBoundColumn> 
                        
                        
                         
                    </Columns> 
                    <DetailTables> 
                     <telerik:GridTableView runat="server" DataSourceID="SqlDataSource1"  > 
                      
                      <Columns> 
                          <telerik:GridBoundColumn DataField="ProductName"    Aggregate="Count" HeaderText="ProductName" SortExpression="ProductName" 
                            UniqueName="ProductName"
                            <HeaderStyle Wrap="True"  /> 
                        </telerik:GridBoundColumn> 
                        
                        <telerik:GridBoundColumn Aggregate="Count" DataField="ProductID"  DataType="System.Int32" HeaderText="ProductID" 
                          SortExpression="ProductID" UniqueName="ProductID"
                        </telerik:GridBoundColumn> 
                        <telerik:GridBoundColumn DataField="SupplierID" DataType="System.Int32" HeaderText="SupplierID" 
                            SortExpression="SupplierID" UniqueName="SupplierID" > 
                        </telerik:GridBoundColumn> 
                        <telerik:GridBoundColumn DataField="CategoryID" DataType="System.Int32" HeaderText="CategoryID" 
                            SortExpression="CategoryID" UniqueName="CategoryID"
                          </telerik:GridBoundColumn> 
                       
                         
                         <telerik:GridBoundColumn DataField="UnitPrice"  DataType="System.Int32"   HeaderText="UnitPrice" SortExpression="UnitPrice" 
                            UniqueName="UnitPrice"
                            <HeaderStyle Wrap="True"  /> 
                        </telerik:GridBoundColumn> 
                        
                        <telerik:GridBoundColumn Aggregate="Count" DataField="QuantityPerUnit"  DataType="System.Int32" HeaderText="QuantityPerUnit" 
                          SortExpression="QuantityPerUnit" UniqueName="QuantityPerUnit"
                        </telerik:GridBoundColumn> 
                        <telerik:GridBoundColumn DataField="UnitsInStock" DataType="System.Int32" HeaderText="UnitsInStock" 
                            SortExpression="UnitsInStock" UniqueName="UnitsInStock" > 
                        </telerik:GridBoundColumn> 
                        <telerik:GridBoundColumn DataField="UnitsOnOrder" DataType="System.Int32" HeaderText="UnitsOnOrder" 
                            SortExpression="UnitsOnOrder" UniqueName="UnitsOnOrder"
                          </telerik:GridBoundColumn> 
                           
                          <telerik:GridBoundColumn DataField="ReorderLevel" DataType="System.Int32" HeaderText="ReorderLevel" 
                            SortExpression="ReorderLevel" UniqueName="ReorderLevel" > 
                        </telerik:GridBoundColumn> 
                        <telerik:GridBoundColumn DataField="Discontinued" DataType="System.Int32" HeaderText="Discontinued" 
                            SortExpression="Discontinued" UniqueName="Discontinued"
                          </telerik:GridBoundColumn> 
                           
                        
                       </Columns> 
                          
                     </telerik:GridTableView> 
                    </DetailTables> 
                     
                </MasterTableView> 
            </telerik:RadGrid> 


Thanks
Shinu.
0
Geoffrey
Top achievements
Rank 1
answered on 27 May 2008, 03:05 PM
I have a similar need as Robert. However, all I want to do is SELECT. I modified the aspx code for my needs (i.e. different column names, used an ObjectDataSourceControl instead of a SqlDataSourceControl) and couldn't get it to work. The MasterTableView correctly shows all of the rows and the four columns that I declared in <Columns>. When I click to expand the row, I get ALL of the rows again and whatever columns i declared in <Columns> for the DetailView. What I expected to see was only those DetailView columns for the selected record.

It seems like I need a separate datasource for the DetailView. Any suggestions? Thanks.

0
Robert
Top achievements
Rank 1
answered on 27 May 2008, 03:08 PM
Amen. I need this answer too.

It would seem that you need 2 datasources (1 for ALL records, 1 for SELECTED record details), but I'm probably wrong.
0
Geoffrey
Top achievements
Rank 1
answered on 27 May 2008, 03:28 PM
I'll open a support ticket right now to expedite this.
Tags
Grid
Asked by
Robert
Top achievements
Rank 1
Answers by
Shinu
Top achievements
Rank 2
Geoffrey
Top achievements
Rank 1
Robert
Top achievements
Rank 1
Share this question
or