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

Hierarchy Grid - One Parent has Two Child

3 Answers 63 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Palanivelrajan
Top achievements
Rank 1
Palanivelrajan asked on 10 Sep 2013, 07:54 AM
Dear All,

I have requirement to display one parent and two child record in the following approach.
First Display all the parent record in the Grid(First column would have Two images)
on clicking the first image on the first column of each row, It should expand with respective child1 table record.
on clicking the second image on the first column of each row, It should expand with respective child2 table record.

We could do for one parent and one child with expand and collapse behavior as given below.
protected void Page_Load(object sender, EventArgs e)
{
     grdSearch.DataSource = dsSearchMeetingList.Tables[0];
     grdSearch.DataBind();
}
protected void grdSearch_DetailTableDataBind(object sender, GridDetailTableDataBindEventArgs e)
{
      GridDataItem dataItem = (GridDataItem)e.DetailTableView.ParentItem;
      int iGolalId = Convert.ToInt32(dataItem.GetDataKeyValue("Pk_Id").ToString());
      grdSearch.DataSource = objViewMaintenance.GetDetailGoals(iGolalId); ;
}

but we want same thing with one parent and two child. based on user click on image1/image 2 on each row, we have to display respective child table record. 

Requesting your help to resolve this.

Note: Attached the sample image for your reference.


With Regards
Palanivelrajan




3 Answers, 1 is accepted

Sort by
0
Vasil
Telerik team
answered on 12 Sep 2013, 01:09 PM
Hello Palanivelrajan,

See this demo that shows how to display 2 detail tables on 1 level.
http://demos.telerik.com/aspnet-ajax/grid/examples/hierarchy/twotablesatlevel/defaultcs.aspx
Next step is to create a TemplateColumn in your main grid, that to hold the 2 buttons. On click of these buttons, you can set Visible=true or Visible=false for the inner tables.

Regards,
Vasil
Telerik
If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the RadControls for ASP.NET AJAX, subscribe to the blog feed now.
0
Palanivelrajan
Top achievements
Rank 1
answered on 15 Sep 2013, 04:19 PM
Dear Vasil,

Thanks for timely reply.

Please let me know following things.

On Click of TemplateColumn which has button with image in the parent table, how to expand and show the child table. How to raise that event on click of TemplateColumn since I am not using default expand and collapse column which raise event internally.

similarly after expand if user click on the same TemplateColumn, it should collapse. Here one more thing if one row is expanded and user try to expand other parent row, how to collapse previous expanded child row.

With Regards
Palanivelrajan




0
Vasil
Telerik team
answered on 19 Sep 2013, 03:35 PM
Hello Palanivelrajan,

There are two ways:
One option is to fire custom command and handle the ItemCommand event of the grid, then get the current item from the arguments of the event handler and expand it:
http://www.telerik.com/help/aspnet-ajax/grid-gridtableview-firecommand.html
The second option is to handle Click event of your buttons, and use sender.Parent to get the item in where they are located and expand it.

Regards,
Vasil
Telerik
If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the RadControls for ASP.NET AJAX, subscribe to the blog feed now.
Tags
Grid
Asked by
Palanivelrajan
Top achievements
Rank 1
Answers by
Vasil
Telerik team
Palanivelrajan
Top achievements
Rank 1
Share this question
or