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
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
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.
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
Hi,
Is it possible to access original data-source value while copying / exporting for output it with different format?
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