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

Problem with Grid Export.

0 Answers 60 Views
GridView
This is a migrated thread and some comments may be shown as answers.
This question is locked. New answers and comments are not allowed.
SivaPrasad Bevara
Top achievements
Rank 1
SivaPrasad Bevara asked on 03 May 2012, 12:49 PM
Hi,

I am using Telerik controls for Silverlight (Version: 2012.1.215.1050).

I am using gridView.ToCSV() method to export the data to a CSV file.
Its working well If I exports all the records from the grid.

But in my case, I need to upload the records which are active, and the Column order in the exported file should be same as the grid column order.

If I use the gridview.Items.Remove(item) and then export then, it is removing the item from the grid also. So I cant use this.

I tried creating a new GridView and attacching the gridview items by checking the active condition. In this case the column order in the exported file is not similar to the grid displayed. In the exported file the columns are in the alphabetical order.

Please suggest a way for exporting the "Active" records, with the column order same as the grid displayed.

private void FileExport(Object commandParameter)
        {
            RadGridView dgGrid = commandParameter as GVDataGrid;
            ObservableCollection<EmployeeDTO> CItems = new ObservableCollection<EmployeeDTO>();
  
            EmployeeDTO emp;
             
            for (int item = 0; item < dgGrid.Items.Count; item++)
            {
                emp = dgGrid.Items[item] as EmployeeDTO;
                if (emp.Status != "Inactive")
                {
                    CItems.Add(client);
                }
            }
  
            RadGridView exportGrid = new RadGridView();
            exportGrid.ItemsSource = CItems; 
            string strFileContent = exportGrid.ToCsv(true);
            ExportFile(strFileContent);
        }

Regards,
SivaPrasad.B
Tags
GridView
Asked by
SivaPrasad Bevara
Top achievements
Rank 1
Share this question
or