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

Creating [Tooltip]+[Export button] in Hierarchy Radgrid.

6 Answers 78 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Emmanuel
Top achievements
Rank 1
Emmanuel asked on 31 Jan 2014, 06:47 PM
Hello.

I'm new in this forum, and i hope someone can help me...


_______

My issue is:

(1)-I made a dynamic hierarchy radgrid: one main table [filled dinamically by one dataset ], second table [filled dinamically with other dataset], third table [filled dinamically with dataset], and the fourth the same as the others.

I want to add a new "column", in this grid and reflect it in the other hierarchy sub tables filled by those datasets, and this column having a button or something to export that "select" dataset. 

NOTE: My dataset is sended by WCF via Stored procedure made with SQL 2008.

 (2).- In these hierarchy radgrid, i want to put inside a Tooltip filled with other Tsql consult (stored procedure), maybe sended as a list <t>, and if someone make click in one row the tooltip make a consult into my database and show me a name for example. All of this using WCF (Windows Communication Foundation)..


 I hope, someone can help me....



The column exporting is what i want to solve first.... 

 Have a nice day.






6 Answers, 1 is accepted

Sort by
0
Angel Petrov
Telerik team
answered on 05 Feb 2014, 01:59 PM
Hello Emmanuel,

Regarding the export functionality. I am not sure how is the grid created(programmatically or directly in the markup) but in order to achieve the desired effect you should add a GridButtonColumn or a GridTemplateColumn with a button in the ItemTemplate which to fire the export. For example if we follow the second approach and attach a click event for the button, in the event handler you can do something like this.
protected void ExportButton_Click(object sender, EventArgs e)
   {
       ((sender as Button).NamingContainer as GridDataItem).OwnerTableView.ExportToExcel();
   }

The second questions however I am experiencing difficulties understanding. Could you please include some code sample and a more detail explanation of it so that we can get a better understanding of the requirement?

Regards,
Angel Petrov
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 UI for ASP.NET AJAX, subscribe to the blog feed now.
0
Emmanuel
Top achievements
Rank 1
answered on 05 Feb 2014, 03:12 PM
Hi

Thanks for help me..

i just changed the way to export an excel report, i change the native radgrid export to excel ML settings to a open source library called NPOI, and now i can export one dataset with multiple tables on it (each one retrieved from any table open via hiearchy radgrid), so that point is solved.

Now, the second one is to insert a tool tip into one or many tables (grids), derived by the master tablegrid, the grid was created by template and filled by code. Something like this.
1.Radgrid1.Datasource = ds;
2.Radgrid1.Databind();

and for the derivated grids, something like this:

01.public void Rdgrid1_DetailTableDataBind(object source, GridDetailTableDataBindEventArgs e)
02.    {
03.        GridDataItem dataItem = (GridDataItem)e.DetailTableView.ParentItem;
04. 
05.        switch (e.DetailTableView.Name)
06.{
07.case: "Table1":
08.{
09.e.DetailTableView.Datasource = ds2
10.break;
11.}
12.}

This is an example of my code...

Thanks for the help..

Greetings






0
Accepted
Angel Petrov
Telerik team
answered on 10 Feb 2014, 09:35 AM
Hi Emmanuel,

I am glad that you were able to resolve the export issue.

As for the insertion of a tool tip you can try integrating the approach demonstrated in this online demo. By subscribing to the grids OnItemDataBound event you can add controls to the TargetControls collection of the
RadToolTipManager and later display the related information according to the preferences.

I want to point out one thing which I noticed from the provided code. The grid seems configured to use simple data-binding(calling .DataBind()). Note that this type of binding is not supported when a hierarchical structure will be used. In such cases we recommend the use of advanced data-binding instead(more about it can be found here).

Regards,
Angel Petrov
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 UI for ASP.NET AJAX, subscribe to the blog feed now.
0
Emmanuel
Top achievements
Rank 1
answered on 11 Feb 2014, 02:01 PM
Hi, Thanks for your answers, there were really helpfull.

I finished my project, and now i can see my data via hierarchy radgrid, so that task is completed. I will check for the advanced data binding. In this case, i used the simple data binding because i filled my grid with datasets, each one called by a WCF (Windows Communication Foundation) service, and the parameters i needed to fill the consecutive grids (child grids from master grid), were taken by 2 global variables and the datakeynames from the table (grid in this case), and that's why i could solve my problem.

In the case of the tooltip, i inserted one just like the web example, and works fine; and also using that library (NPOI), for exporting to excel, i haven't any trouble to export all my tables ( Creating a new dataset and then inserted into them all the tables when i open a new child grid, so my dataset was filled by multiples tables and when i needed to export, all the tables into the dataset were converted in a excel sheet, so one excel document have multiple sheets from the multiple tables (grids) i've been opened before)

I hope my english goes well, but in few words, everything was fine.

I really appreciate your help, and the resources contains in this forum.

Regards, and thanks again for your helpfull information. 

Have a nice day.
0
Asutosh
Top achievements
Rank 1
answered on 17 Jun 2014, 12:05 PM
hi

i am exporting heirarchy radgrid in excel

how to export radgrid in excel without OnNeedDataSource

i am binding datasource to radgrid on button click event 

if i am not use OnNeedDataSource,it give me object reference is null

my code for binding grid is 

 grd_firstchart_aco.DataSource = table;

 grd_firstchart_aco.DataBind();
and code for export to excel is below
  grd_forth_aco.ExportSettings.ExportOnlyData = true;
        grd_forth_aco.ExportSettings.IgnorePaging = true;
        grd_forth_aco.ExportSettings.OpenInNewWindow = true;
        grd_forth_aco.ExportSettings.FileName = "fileName";
        grd_forth_aco.ExportSettings.Excel.Format = GridExcelExportFormat.ExcelML;
        grd_forth_aco.ExportSettings.HideStructureColumns = true;

        grd_forth_aco.MasterTableView.HierarchyDefaultExpanded = true;
        grd_forth_aco.MasterTableView.DetailTables[0].HierarchyDefaultExpanded = true;

        grd_forth_aco.MasterTableView.HierarchyLoadMode = GridChildLoadMode.Client;
        grd_forth_aco.MasterTableView.DetailTables[0].HierarchyLoadMode = GridChildLoadMode.Client;

        grd_forth_aco.MasterTableView.ExportToExcel();
thanks


0
Angel Petrov
Telerik team
answered on 19 Jun 2014, 01:57 PM
Hello Asutosh,

I am sorry to say but exporting a hierarchical structure with simple data-biding is not supported. In order to make things work correctly I would recommend binding the grid in the NeedDataSource event as suggested by my colleague Kostadin in the other thread you have opened regarding this matter.

From the information provided there it seems that you need to filter the RadGrid data source in the PageLoad event. If that is the case you can construct a temporary data source, filter it in the mentioned event and later assign it as a data source for the grid in the NeedDataSource event handler. By following this approach you should be able to make things work correctly.

Finally, I want to ask you to post your questions in a single thread. That way we will be able to better track the progress of the matter and provide a faster and more precise answer.

Regards,
Angel Petrov
Telerik
 

Check out the Telerik Platform - the only platform that combines a rich set of UI tools with powerful cloud services to develop web, hybrid and native mobile apps.

 
Tags
Grid
Asked by
Emmanuel
Top achievements
Rank 1
Answers by
Angel Petrov
Telerik team
Emmanuel
Top achievements
Rank 1
Asutosh
Top achievements
Rank 1
Share this question
or