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

Unable to export Grid Row which is not visible

1 Answer 40 Views
GridView
This is a migrated thread and some comments may be shown as answers.
saurabh
Top achievements
Rank 1
saurabh asked on 20 Jul 2010, 09:52 AM

Earlier we are using the Telerik Export Functionality. But if any row has null value it is not able to export the grid. So we have decied to create our one Export functionality. It is working fine but we are not able to export those data which is not visible in grid Right Now. After 15 Record it repeat the same row again and again. we are able to export those records which is visible. we tried to scroll down the record through coding but it still not working. Please suggest.

Actual Error:

1. Suppose Currently we have 100 Record in Grid and Page Size is 50. Currently we are able to see first 15 Records, Rest we can see if we scroll down and Record No : 1 is selected Record.

After Export: it exports all the 15 record correctly after 16th onwards it start repeating the same record no 16 till 100.

2. Suppose Currently we have 100 Record in Grid and Page Size is 50. Currently we are able to see 15 to 30 Records, Rest we can see if we scroll down and Record No : Record 35 is selected Record.

After Export: First it exports record No : 35 and  then 15 to 30 records after that it start repeating the 30th record till 100.

How can we generate the UI of invisible Records?

Source Code Used for Exporting the Grid. 

public string ExportDataGrid(bool withHeaders, RadGridView grid)

{

if (grid.ItemsSource == null)

return string.Empty;

System.Text.StringBuilder strBuilder = new System.Text.StringBuilder();

 

List<string> headers = new List<string>();

for (int i = 0; i < grid.Columns.Count; i++)

{

if(grid.Columns[i].IsVisible == true)

headers.Add(FormatCSVField(grid.Columns[i].Header.ToString()));

}

strBuilder.Append(String.Join(",", headers.ToArray())).Append("\r\n");

List<string> csvRow = new List<string>();

for (int j = 0; j < grid.Items.Count; j++)

{


grid.SetIsCurrent( grid.Items[j]);

grid.ScrollIntoView(grid.CurrentItem);

GridViewRow gvr = (GridViewRow)grid.ItemContainerGenerator.ContainerFromItem(grid.CurrentItem );

//Return the UI Element corrosponding to Given Item. Returns Null if the item doesn't belong to the item Collection or if No UI Has been generated for it.

csvRow.Clear();

 

foreach (GridViewCell gridViewCell in gvr.Cells)

{

if(gridViewCell.Column.IsVisible == true)


csvRow.Add(FormatCSVField((gridViewCell.Value == null ? string.Empty : gridViewCell.Value.ToString())));

}

 

strBuilder.Append(String.Join(",", csvRow.ToArray())).Append("\r\n");

}

return strBuilder.ToString();

}

1 Answer, 1 is accepted

Sort by
0
Veselin Vasilev
Telerik team
answered on 20 Jul 2010, 09:55 AM
Hi saurabh,

Please use our latest version - Q2 which contains a fix for exporting NULL values.

In addition, you can check the approach shown in this online demo: Exporting Paged Data.

All the best,
Veskoni
the Telerik team
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
Tags
GridView
Asked by
saurabh
Top achievements
Rank 1
Answers by
Veselin Vasilev
Telerik team
Share this question
or