To reproduce: open the Demo application >> VirtualGrid >> First Look example. Follow the steps illustrated in the attached gif file. You will notice that when you expand a row, the "-" sign is show for a second and then it is returned to "+" although the row is still expanded.
Workaround:
this.radVirtualGrid1.CellFormatting += radVirtualGrid1_CellFormatting;
this.radVirtualGrid1.RowExpanded += radVirtualGrid1_RowExpanded;
this.radVirtualGrid1.RowCollapsed += radVirtualGrid1_RowCollapsed;
private void radVirtualGrid1_RowCollapsed(object sender, VirtualGridRowExpandedEventArgs e)
{
if (expandedState.ContainsKey(e.RowIndex))
{
expandedState[e.RowIndex] = !expandedState[e.RowIndex];
}
this.radVirtualGrid1.TableElement.SynchronizeRow(e.RowIndex, true);
}
Dictionary<int, bool> expandedState = new Dictionary<int, bool>();
private void radVirtualGrid1_RowExpanded(object sender, VirtualGridRowExpandedEventArgs e)
{
if (!expandedState.ContainsKey(e.RowIndex))
{
expandedState.Add(e.RowIndex, false);
}
expandedState[e.RowIndex] = !expandedState[e.RowIndex];
this.radVirtualGrid1.TableElement.SynchronizeRow(e.RowIndex, true);
}
private void radVirtualGrid1_CellFormatting(object sender, Telerik.WinControls.UI.VirtualGridCellElementEventArgs e)
{
VirtualGridIndentCellElement indentCell = e.CellElement as VirtualGridIndentCellElement;
if (indentCell != null)
{
if (expandedState.ContainsKey(e.CellElement.RowIndex) && expandedState[e.CellElement.RowIndex] == true)
{
indentCell.ExpanderItem.SignImage = Properties.Resources.chevron_up;
}
else
{
indentCell.ExpanderItem.SignImage = Properties.Resources.chevron_down;
}
}
}