Problem with Grid Export.

1 posts, 0 answers
  1. SivaPrasad Bevara
    SivaPrasad Bevara avatar
    73 posts
    Member since:
    Oct 2012

    Posted 03 May 2012 Link to this post


    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")
                RadGridView exportGrid = new RadGridView();
                exportGrid.ItemsSource = CItems; 
                string strFileContent = exportGrid.ToCsv(true);

Back to Top