Easy way to get a report from a filtered radgridview??

3 Answers 106 Views
GridView
Udo
Top achievements
Rank 1
Iron
Udo asked on 18 Jan 2022, 12:06 PM

Hi there ,

I have a WindowsForms application with a RadGridView.
Now I would like to output the filtered values ​​as a report or transfer them to a report.
Is there an easy way?

Thanks

Udo

3 Answers, 1 is accepted

Sort by
0
Todor
Telerik team
answered on 18 Jan 2022, 01:06 PM

Hi, Udo,

RadGridView offers ChildRows collection which returns the data rows that are currently represented by RadGridView in the order in which they appear. The collection is modified every time a data operation (e.g. filtering) occurs. It is possible to populate programmatically a DataTable considering the content of the ChildRows collection. Then, use this DataTable for generating the report. 

For the reporting part, you need to create a report definition that reflects the desired layout. You may check our Getting Started articles for details. You will have to use an ObjectDataSource component that points to the DataTable generated from the RadGridView. Finally, you may display the report in our WinForms Report Viewer.

Regards,
Todor
Progress Telerik

Virtual Classroom, the free self-paced technical training that gets you up to speed with Telerik and Kendo UI products quickly just got a fresh new look + new and improved content including a brand new Blazor course! Check it out at https://learn.telerik.com/.

0
Udo
Top achievements
Rank 1
Iron
answered on 18 Jan 2022, 04:46 PM | edited on 19 Jan 2022, 11:22 AM

Hi there,

how can I write the ChildRowSelection to a Datatable?

I need Help please!!.

 

Thanks for Help

Udo

Dess | Tech Support Engineer, Principal
Telerik team
commented on 19 Jan 2022, 12:12 PM

Hello, Udo, 

I have prepared a sample code snippet demonstrating how to generate a DataTable populated with the data from the filtered RadGridView:
            DataTable dt = new DataTable();
            foreach (GridViewColumn col in this.radGridView1.Columns)
            {
                dt.Columns.Add(col.Name);
            }
            foreach (GridViewRowInfo row in this.radGridView1.ChildRows)
            {
                DataRow dr = dt.NewRow();
                foreach (GridViewColumn col in this.radGridView1.Columns)
                {
                    dr[col.Name] = row.Cells[col.Name].Value;
                }
                dt.Rows.Add(dr);
            }
I hope this information helps. If you need any further assistance please don't hesitate to contact me. 
0
Udo
Top achievements
Rank 1
Iron
answered on 19 Jan 2022, 06:42 PM

Tank You.

It works perfect

Tags
GridView
Asked by
Udo
Top achievements
Rank 1
Iron
Answers by
Todor
Telerik team
Udo
Top achievements
Rank 1
Iron
Share this question
or