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

How to access the Grid Value for RadGridView ??

8 Answers 246 Views
GridView
This is a migrated thread and some comments may be shown as answers.
Munish
Top achievements
Rank 1
Munish asked on 05 Feb 2014, 01:45 PM
Hi All
I have a RadGridView in my code of the namespace "Telerik.Windows.Controls.RadGridView". I need to iterate through the rows and get all the data. I am using the code as :
IList<GridViewRow> rows = RadGridView1.ChildrenOfType<GridViewRow>();
foreach (GridViewRow row in rows)
 {if (!(row is GridViewNewRow))
{foreach (var x in row.Cells)
                    {
                        GridViewCell y = (GridViewCell)x;
                        System.Diagnostics.Debug.WriteLine(y.Value);     
                    }}}

The value comes as null if the column if is of type checkbox. I need some generic code to get the value. 

Anybody any idea about this ??









8 Answers, 1 is accepted

Sort by
0
Munish
Top achievements
Rank 1
answered on 05 Feb 2014, 01:47 PM
I have seen there are few solutions on telerik website ..but they are using the namespace Telerik.WinControls....i dont have this dll reference to me.
0
Dimitrina
Telerik team
answered on 05 Feb 2014, 04:01 PM
Hello,

My suggestion is that you iterate on the bound data items instead. You can access them through RadGridView.Items.

Regards,
Didie
Telerik
TRY TELERIK'S NEWEST PRODUCT - EQATEC APPLICATION ANALYTICS for WPF.
Learn what features your users use (or don't use) in your application. Know your audience. Target it better. Develop wisely.
Sign up for Free application insights >>
0
Munish
Top achievements
Rank 1
answered on 05 Feb 2014, 05:27 PM
Hi 

Thanks for the revert. The items gives me the view model. Each row in my grid is an instance of view model. Issues in that :

1. For each column name , i Need to access the corresponding property of the VM using some select statement. ( Sort of mapping between column and VM property)

2.Property in VM returns the plain data , where as GUI is showing value after conversion ( Converters defined in the XAML).


0
Dimitrina
Telerik team
answered on 05 Feb 2014, 05:34 PM
Hello,

Indeed, in that case you can only work with the plain data. I should mention that when the UI Virtualization is enabled, we do not recommend you to rely on the visual elements. 

Regards,
Didie
Telerik
TRY TELERIK'S NEWEST PRODUCT - EQATEC APPLICATION ANALYTICS for WPF.
Learn what features your users use (or don't use) in your application. Know your audience. Target it better. Develop wisely.
Sign up for Free application insights >>
0
Munish
Top achievements
Rank 1
answered on 06 Feb 2014, 04:18 AM
Well , I have seen the telerik export csv functionality too....It accepts the underlying dataitems to the API...but still the value in exported file is same as shown in the GUI itself , i.e after appyling the converters.
0
Dimitrina
Telerik team
answered on 06 Feb 2014, 07:44 AM
Hello,

I am afraid that there is not an option to export the raw data by default. You can format the exported value back in the ElementExporting event of the RadGridView.

Regards,
Didie
Telerik
TRY TELERIK'S NEWEST PRODUCT - EQATEC APPLICATION ANALYTICS for WPF.
Learn what features your users use (or don't use) in your application. Know your audience. Target it better. Develop wisely.
Sign up for Free application insights >>
0
Ed
Top achievements
Rank 1
answered on 11 Feb 2014, 05:07 AM
" You can access them through RadGridView.Items"

I'm a newbie especially with the RadGridView so it would be helpful if you can you provide an example.  
0
Dimitrina
Telerik team
answered on 12 Feb 2014, 12:34 PM
Hello,

You can check our Exporting WPF Demos and our online documentation on how to export and format the data based on the ExportFormat you use. Do you export to CSV format?

Regards,
Didie
Telerik

Check out the new Telerik Platform - the only modular platform that combines a rich set of UI tools with powerful cloud services to develop web, hybrid and native apps. Register for the free online keynote and webinar to learn more about the Platform on Wednesday, February 12, 2014 at 11:00 a.m. ET (8:00 a.m. PT).

Tags
GridView
Asked by
Munish
Top achievements
Rank 1
Answers by
Munish
Top achievements
Rank 1
Dimitrina
Telerik team
Ed
Top achievements
Rank 1
Share this question
or