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

[HELP] Expand button in RadGrid

9 Answers 264 Views
Grid
This is a migrated thread and some comments may be shown as answers.
trunghieu
Top achievements
Rank 1
trunghieu asked on 23 Apr 2011, 11:04 PM
Hello,i'm Student,i'm studying about RadGrid,i have some problem ,plz help me
I have 2 table that's Customer and Bill,i also 2 RadGrid , i want Radgrid1 containing Customer Information and Radgrid2 (In <NestedViewTemplate> )  containing  Bill information with condition is CustomerID= Value when i click Expand
What's should i do ?
http://nguy-hiem.co.cc/share/567.png

THANKS !

9 Answers, 1 is accepted

Sort by
0
Marin
Telerik team
answered on 28 Apr 2011, 08:35 AM
Hello trunghieu,

Have look at this online demo showing hierarchy in RadGrid with NestedViewTemplate. Basically you need to use the ParentTableRelation setting and specify there the MasterKeyField and DetailKeyField properties in order to relate the two table.

Greetings,
Marin
the Telerik team

Browse the vast support resources we have to jump start your development with RadControls for ASP.NET AJAX. See how to integrate our AJAX controls seamlessly in SharePoint 2007/2010 visiting our common SharePoint portal.

0
trunghieu
Top achievements
Rank 1
answered on 14 May 2011, 08:16 AM
Hello, in this demo ,how to get value of contact name when expanded (using c# code)

THANK !
0
Marin
Telerik team
answered on 17 May 2011, 07:32 PM
Hi trunghieu,

 You can have a look at this help article showing how you can access a value from a cell of the grid.

Regards,
Marin
the Telerik team

Browse the vast support resources we have to jump start your development with RadControls for ASP.NET AJAX. See how to integrate our AJAX controls seamlessly in SharePoint 2007/2010 visiting our common SharePoint portal.

0
trunghieu
Top achievements
Rank 1
answered on 18 May 2011, 05:32 AM
Thank you, but because i using c# get data from datatable into Radgrid so i can't use GridBoundColumn, can you help me ?  i want when i expanded , i will get CustomerID or OrderID,generally ,i want getting primary key when i expanded ( using C#)
THANK A LOT !

0
Marin
Telerik team
answered on 18 May 2011, 12:11 PM
Hi trunghieu,

 You can use the GetDataKeyValue method of the grid item, but you should have set the primary key as DataKeyName for the grid.

<telerik:RadGrid ID="RadGrid1" runat="server" ...>
            <MasterTableView DataKeyNames="CustomerID">

protected void grid_ItemCommand(object sender, GridCommandEventArgs e)
    {
        if (e.CommandName == RadGrid.ExpandCollapseCommandName)
        {
            //CustomerID should be set as DataKeyNames for the parent in order for this code to work correctly
            var id = (e.Item as GridDataItem).GetDataKeyValue("CustomerID");
        }
    }

Greetings,
Marin
the Telerik team

Browse the vast support resources we have to jump start your development with RadControls for ASP.NET AJAX. See how to integrate our AJAX controls seamlessly in SharePoint 2007/2010 visiting our common SharePoint portal.

0
trunghieu
Top achievements
Rank 1
answered on 21 May 2011, 06:24 PM
Thank you very much,i just have a question, you can see in this link
http://nguy-hiem.co.cc/share/ask.png (what's event i can use in RadGrid2)

THANK
0
Princy
Top achievements
Rank 2
answered on 23 May 2011, 10:24 AM
Hello Trunghieu,

Check whether the CommandName  is "ExpandCollapse" and also check for OwnerTableView's Name in ItemCommand event. Hope this helps you.
C#:
protected void RadGrid2_ItemCommand(object sender, GridCommandEventArgs e)
 {
       if (e.CommandName == "ExpandCollapse" && e.Item.OwnerTableView.Name == "DetailTable")
       {
       //your code
       }
  }

Thanks,
Princy
0
trunghieu
Top achievements
Rank 1
answered on 23 May 2011, 02:45 PM
Thank , but not run because RadGrid2 in  NestedViewTemplate Tag of RadGrid1
0
trunghieu
Top achievements
Rank 1
answered on 28 May 2011, 06:43 AM
please Help me
Tags
Grid
Asked by
trunghieu
Top achievements
Rank 1
Answers by
Marin
Telerik team
trunghieu
Top achievements
Rank 1
Princy
Top achievements
Rank 2
Share this question
or