Srinivas Nilagiri
Top achievements
Rank 1
Srinivas Nilagiri
asked on 10 Dec 2009, 07:04 AM
Hi All,
I have an hierarchical grid with 3 levels (MasterTableView and 2 DetailTables) and <telerik:GridClientSelectColumn /> in the inner most view.
I want to export only those rows selected in the inner most view along with their parent view rows.
Could not find a solution to get the selected rows ids and export only the selected. Please help me to point to the right resource to resolve the issue. Thanks.
4 Answers, 1 is accepted
0
Hi Srinivas,
Please find attached a simple working application which handles the desired functionality. Give it a try and let me know if it works as expected.
I hope this helps.
Greetings,
Pavlina
the Telerik team
Instantly find answers to your questions on the new Telerik Support Portal.
Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
Please find attached a simple working application which handles the desired functionality. Give it a try and let me know if it works as expected.
I hope this helps.
Greetings,
Pavlina
the Telerik team
Instantly find answers to your questions on the new Telerik Support Portal.
Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
0
Shinu
Top achievements
Rank 2
answered on 10 Dec 2009, 08:30 AM
Hi Srinivas,
Here is the code that I tried in order to accomplish the scenario.
CS:
-Shinu.
Here is the code that I tried in order to accomplish the scenario.
CS:
| protected void Button1_Click(object sender, EventArgs e) |
| { |
| RadGrid1.ExportSettings.ExportOnlyData = true; |
| RadGrid1.ExportSettings.OpenInNewWindow = true; |
| foreach(GridDataItem mItem in RadGrid1.MasterTableView.Items) |
| { |
| if (mItem.Expanded) |
| { |
| foreach (GridDataItem childItem in mItem.ChildItem.NestedTableViews[0].Items) |
| { |
| if (childItem.Expanded) |
| { |
| foreach (GridDataItem subchildItem in childItem.ChildItem.NestedTableViews[0].Items) |
| { |
| if (!subchildItem.Selected) |
| subchildItem.Visible = false; |
| } |
| } |
| else |
| { |
| childItem.Visible = false; |
| } |
| } |
| } |
| else |
| { |
| mItem.Visible = false; |
| } |
| } |
| RadGrid1.MasterTableView.ExportToExcel(); |
| } |
-Shinu.
0
Srinivas Nilagiri
Top achievements
Rank 1
answered on 10 Dec 2009, 09:39 AM
Thank you Pavlina and Shinu for your help. I think I missed out some details in my orinal posting.
1. my grid is ajaxified
2. I am using client side row select and unselect events and preserving the selection using
3. HierarchyDefaultExpanded is set to true as per user requirement.
my <telerik:GridClientSelectColumn /> is only in the 2nd Details Table of the Grid. So I can not start from MasterTableView and detect whether the master row is selected or not. I can only proceed in the reverse way.
I tried to implement Pavlina solution and able to achieve a portion of my requirement using the code.
Now I can export only the records selected in the DetailTable2. But I need to hide the MasterTableView rows and DetailTable1 rows if not atleast one DetailTable2 row is selected.
Shinu's solution is not working may be because my grid is ajaxified. Thanks for the help.
1. my grid is ajaxified
2. I am using client side row select and unselect events and preserving the selection using
| <ClientEvents OnRowCreated="grdJobsDone_RowCreated" OnRowSelected="grdJobsDone_RowSelected" OnRowDeselected="grdJobsDone_RowDeselected" /> |
my <telerik:GridClientSelectColumn /> is only in the 2nd Details Table of the Grid. So I can not start from MasterTableView and detect whether the master row is selected or not. I can only proceed in the reverse way.
I tried to implement Pavlina solution and able to achieve a portion of my requirement using the code.
| protected void grdJobsDone_PreRender(object sender, EventArgs e) |
| { |
| //foreach (GridDataItem dataItem in grdJobsDone.MasterTableView.Items) |
| //{ |
| // if (ViewState["shouldHide"] != null && Boolean.Parse(ViewState["shouldHide"].ToString()) == true) |
| // { |
| // dataItem.Visible = dataItem.Selected; |
| // dataItem.Expanded = dataItem.Selected; |
| // } |
| //} |
| if (Session["selectedItems"] != null) |
| { |
| ArrayList selectedItems = (ArrayList)Session["selectedItems"]; |
| foreach (GridDataItem dataItem in grdJobsDone.Items) |
| { |
| if (dataItem.OwnerTableView.Name == "JobsDone") |
| { |
| if (selectedItems.Contains(dataItem.OwnerTableView.DataKeyValues[dataItem.ItemIndex]["JobCode"].ToString())) |
| { |
| dataItem.Visible = true; |
| } |
| else { |
| dataItem.Visible = false; |
| } |
| } |
| } |
| Session["selectedItems"] = null; |
| } |
| } |
Now I can export only the records selected in the DetailTable2. But I need to hide the MasterTableView rows and DetailTable1 rows if not atleast one DetailTable2 row is selected.
Shinu's solution is not working may be because my grid is ajaxified. Thanks for the help.
0
Hello Srinivas,
At this point in order to progress in the resolution of this matter, please open a formal support ticket and send us a small working project, demonstrating your logic, and the unwanted behavior. We will review it locally, and advise you further.
Sincerely yours,
Pavlina
the Telerik team
Instantly find answers to your questions on the new Telerik Support Portal.
Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
At this point in order to progress in the resolution of this matter, please open a formal support ticket and send us a small working project, demonstrating your logic, and the unwanted behavior. We will review it locally, and advise you further.
Sincerely yours,
Pavlina
the Telerik team
Instantly find answers to your questions on the new Telerik Support Portal.
Watch a video on how to optimize your support resource searches and check out more tips on the blogs.