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

Difference between copying cell value using IEnumerable and IQueryable

5 Answers 83 Views
GridView
This is a migrated thread and some comments may be shown as answers.
nagibator4000
Top achievements
Rank 1
nagibator4000 asked on 29 May 2017, 11:05 AM

Hello everyone.

I have noticed a strange RadGridView's behavior when I'm copying value from decimal cell (with DataFormat string) or exporting grid content to Excel. 

If I use IQueryable as GridView ItemsSource, there is copied value the same as on-screen value. For example, I have a value 1000000 in data source and {0:N2} as DataFormatString, and a result value displayed in cell will be "1 000 000,00". When I copy this cell via Ctrl+C or export the datagrid to Excel, the result will be also "1 000 000,00", string with spaces between digits, not number. Math functions in Excel cannot be applied for that value.

However, If use IEnumberable instead IQueryable, the exported and pasted values will be absolutely the same as it in DataSource and will have their native type (decimal).

How can I copy the cell value in it native type using IQueryable as data source?

5 Answers, 1 is accepted

Sort by
0
Ivan Ivanov
Telerik team
answered on 01 Jun 2017, 10:04 AM
Hi,

I prepared a project that uses the same data format string for decimal value and has both IEnumerable<T> and IQueryable<T> data sources. However, copying values from both of the gridviews and pasting them in Excel results in a cell with Number format. I am attaching the test project to my post so that you can check whether there are any differences between your approach and mine.

Regards,
Ivan Ivanov
Progress Telerik
Want to extend the target reach of your WPF applications, leveraging iOS, Android, and UWP? Try UI for Xamarin, a suite of polished and feature-rich components for the Xamarin framework, which allow you to write beautiful native mobile apps using a single shared C# codebase.
0
nagibator4000
Top achievements
Rank 1
answered on 01 Jun 2017, 12:12 PM
Hello, Ivan. Thank you for a answer. 

There was a little misconception because I have thought that in project we use RadGridView with IEnumberable<T> data source. 
But actually we use RadTreeListView with IEnumberable<T> instead RadGridView. And when I copy or export data from RadTreeListView it copies without formatting. Is it possible to make TreeListView copies data similar way to GridView (with formatting) or vice versa?

If you replace in your sample one of GridView with RadTreeListView and then try to copy data you'll see that difference. 
0
Ivan Ivanov
Telerik team
answered on 01 Jun 2017, 03:25 PM
Hi,

Thank you for clarifying. I managed to reproduce it on my side. The fix will be available either in the incoming SP or in some of the subsequent releases.

Regards,
Ivan Ivanov
Progress Telerik
Want to extend the target reach of your WPF applications, leveraging iOS, Android, and UWP? Try UI for Xamarin, a suite of polished and feature-rich components for the Xamarin framework, which allow you to write beautiful native mobile apps using a single shared C# codebase.
0
nagibator4000
Top achievements
Rank 1
answered on 05 Jun 2017, 10:41 AM

Hi,

Is it possible to access original data-source value while copying / exporting for output it with different format?

0
Ivan Ivanov
Telerik team
answered on 08 Jun 2017, 10:07 AM
Hello,

There is no dedicated public method that can guarantee that the original value will returned. However, you can either look it up in the original data source, or you can use a utility class that resolves it. I prepared a simple demo that illustrates a possible approach that is based on the WPF data binding mechanism.

Regards,
Ivan Ivanov
Progress Telerik
Want to extend the target reach of your WPF applications, leveraging iOS, Android, and UWP? Try UI for Xamarin, a suite of polished and feature-rich components for the Xamarin framework, which allow you to write beautiful native mobile apps using a single shared C# codebase.
Tags
GridView
Asked by
nagibator4000
Top achievements
Rank 1
Answers by
Ivan Ivanov
Telerik team
nagibator4000
Top achievements
Rank 1
Share this question
or