I have tried to follow the example in the documentation for XamGrid Export to Excel at http://help.infragistics.com/Help/NetAdvantage/Silverlight/2011.1/CLR4.0/html/SL_Exporting_xamGrid_Data_to_Excel.html, and it does not work in my case. Some of my columns are GroupColumns. For example, the "Security Id" and "Security Name" columns are inside a "Security" GroupColumn. When I implement the Export to Excel logic in codebehind, and loop through the cells of each row, only the GroupCell appears in the collection of cells, and the Value property of this is null.
There are no obvious properties of this object that would allow me to pull the value of the child columns (e.g. Security Id).
How do I implement Export to Excel if my grid uses GroupColumns?
FWIW, I was able to figure it out with the comment Darrel made - here is my code:
if (action == "Copy Cell")
{
foreach (var gcell in ONTsGrid.SelectionSettings.SelectedRows[0].Cells)
if (gcell is GroupCell)
foreach (var col in gcell.Column.AllColumns)
var cell = ONTsGrid.SelectionSettings.SelectedRows[0].Cells[col];
if (cell.IsActive == true)
Clipboard.SetText(cell.Value.ToString());
}
Thanks - this clarification helped as it was not obvious. This works for me now.
Thanks, it is working.
But there is one bug(?): when you hide GroupColumn, its children column don't change property Visibility to Visibility.Collapsed
Hi,
Darrell's approach is actually correct, however there is one additional step.
You can retrieve any cell by passing in a column:
Cell cell = grid.Rows[0].Cells[(Column)grid1.Columns.AllColumns["ColKey"]]
Hope this helps,
-SteveZ
I ran into this problem too. My grid has a context menu on it with a "Copy Cell Value" action and while getting that action to work on a grid without group columns was simple enough, I have yet to be able to figure it out for group columns because I can't find the value for the selected cell at least in the 10 minutes or so I looked at it in the debugger. Hopefully Darrell or someone will get back to us.