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

Export when grouping problems

4 Answers 34 Views
GridView
This is a migrated thread and some comments may be shown as answers.
Robert
Top achievements
Rank 1
Robert asked on 02 Dec 2009, 10:23 AM
Hello,
I have a problem exporting to a text file while grouping the data.

<!-- Window1.xaml --> 
<Window x:Class="WpfTelerikRadGridViewTest.Window1" 
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" 
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" 
    xmlns:telerik="http://schemas.telerik.com/2008/xaml/presentation" 
    Title="Window1" Width="800" Height="600" > 
    <Grid> 
        <Grid.RowDefinitions> 
            <RowDefinition /> 
            <RowDefinition Height="Auto" /> 
        </Grid.RowDefinitions> 
        <telerik:RadGridView Name="radGridView1" ItemsSource="{Binding}" /> 
        <Button Grid.Row="1" Click="ButtonBase_OnClick">Save</Button> 
    </Grid> 
</Window> 


// Window1.xaml.cs  
public partial class Window1  
{  
    public Window1()  
    {  
        InitializeComponent();  
 
        var list = new ObservableCollection<string>();  
 
        list.Add("HELLO1");  
        list.Add("HELLO2");  
        list.Add("HELLO3");  
        list.Add("HELLO4");  
        list.Add("HELLO5");  
 
        DataContext = list;  
    }  
 
    private void ButtonBase_OnClick(object sender, RoutedEventArgs e)  
    {  
        var s = radGridView1.ToText();  
    }  

When i press the save button the variable 's' gets the _correct_ value:
"\r\nHELLO1\r\nHELLO2\r\nHELLO3\r\nHELLO4\r\nHELLO5\r\n"

When i press the save button while grouping the column i get the following value on 's': 
"\r\nHELLO1\r\n\r\nHELLO1\r\nHELLO2\r\n\r\nHELLO1\r\n\r\nHELLO1\r\nHELLO2\r\nHELLO3\r\n\r\nHELLO1\r\n\r\nHELLO1\r\nHELLO2\r\n\r\nHELLO1\r\n\r\nHELLO1\r\nHELLO2\r\nHELLO3\r\nHELLO4\r\n\r\nHELLO1\r\n\r\nHELLO1\r\nHELLO2\r\n\r\nHELLO1\r\n\r\nHELLO1\r\nHELLO2\r\nHELLO3\r\n\r\nHELLO1\r\n\r\nHELLO1\r\nHELLO2\r\n\r\nHELLO1\r\n\r\nHELLO1\r\nHELLO2\r\nHELLO3\r\nHELLO4\r\nHELLO5\r\n\r\nHELLO1\r\n\r\nHELLO1\r\nHELLO2\r\n\r\nHELLO1\r\n\r\nHELLO1\r\nHELLO2\r\nHELLO3\r\n\r\nHELLO1\r\n\r\nHELLO1\r\nHELLO2\r\n\r\nHELLO1\r\n\r\nHELLO1\r\nHELLO2\r\nHELLO3\r\nHELLO4\r\n\r\nHELLO1\r\n\r\nHELLO1\r\nHELLO2\r\n\r\nHELLO1\r\n\r\nHELLO1\r\nHELLO2\r\nHELLO3\r\n\r\nHELLO1\r\n\r\nHELLO1\r\nHELLO2\r\n\r\nHELLO1\r\n\r\nHELLO1\r\nHELLO2\r\nHELLO3\r\nHELLO4\r\nHELLO5\r\n"

This means that i cant export a grid if the user is grouping. I thought that it would generate a sorted grid. This behavior also applies to ToHtml.

4 Answers, 1 is accepted

Sort by
0
Rossen Hristov
Telerik team
answered on 07 Dec 2009, 03:29 PM
Hello Robert,

When you bind the grid to a collection of strings it is their length that is displayed. Maybe this is causing the confusion.

I have prepared a sample project with real data and exporting works fine. Please find the sample project attached. Here is what I get when I group by country and export the grid:

Name    Number  Position    Country
Petr Čech   1   GK  Czech Republic
             
Jamie Carragher 23  DF  England
Steven Gerrard  8   MF  England
Rio Ferdinand   5   DF  England
Wayne Rooney    10  FW  England
John Terry  26  DF  England
Frank Lampard   8   MF  England
             
Nicolas Anelka  39  FW  France
Gaël Clichy 22  DF  France
             
Edwin van der Sar   1   GK  Netherlands
Robin van Persie    11  FW  Netherlands
             
Pepe Reina  25  GK  Spain
Fernando Torres 9   FW  Spain
Manuel Almunia  1   GK  Spain
Cesc Fàbregas   4   MF  Spain
             
Ryan Giggs  11  MF  Wales

I hope this helps.

Kind regards,
Ross
the Telerik team

Instantly find answers to your questions on the new Telerik Support Portal.
Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
0
Robert
Top achievements
Rank 1
answered on 08 Dec 2009, 08:39 AM
Hello Ross
Thanks for the example project! It works great until i change the references to the version of telerik that i have (2009.1.312.35). Then i get the following output. I only took a part of it because it is about 385lines!!

Name    Number  Position    Country  
Petr Čech   1   GK  Czech Republic  
Name    Number  Position    Country  
Petr Čech   1   GK  Czech Republic  
Jamie Carragher 23  DF  England  
Steven Gerrard  8   MF  England  
Rio Ferdinand   5   DF  England  
Wayne Rooney    10  FW  England  
John Terry  26  DF  England  
Frank Lampard   8   MF  England  
Name    Number  Position    Country  
Petr Čech   1   GK  Czech Republic  
Name    Number  Position    Country  
Petr Čech   1   GK  Czech Republic  
Jamie Carragher 23  DF  England
...

again it seems like the data is duplicated.
0
Rossen Hristov
Telerik team
answered on 08 Dec 2009, 09:10 AM
Hello Robert,

You will need to upgrade to our Latest Internal Build version. The version you are using is almost 9 months old. You can download our Latest Internal Build version from your Client.NET.

All the best,
Ross
the Telerik team

Instantly find answers to your questions on the new Telerik Support Portal.
Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
0
Robert
Top achievements
Rank 1
answered on 09 Dec 2009, 08:27 AM
A update fixed the problem, thanks!
Tags
GridView
Asked by
Robert
Top achievements
Rank 1
Answers by
Rossen Hristov
Telerik team
Robert
Top achievements
Rank 1
Share this question
or