To reproduce: open the VirtualGrid >> First Look example in QSF and follow the steps: 1) I have a virtual grid which has both vertical and horizontal scroll bars. 2) Scroll to the very bottom of the grid 3) Select the last row 4) Scroll all the way to the right At this moment the selected row disappears from the view. While scrolling horizontally the vertical scrollbar jumps several rows above although it seems scrolled to the bottom.
I miss grouping functionality in VirtualGrid. In my opinion, the following process would be conceivable: 1. user interaction triggers an event - e. g. GroupChanged (similar to FilterChanged). 2. This event determines all available groups and returns them to the VirtualGrid. 3. if the user expand a group > a second event is fired - and returns all matching data rows.
Repro-steps:
Expected behavior:
Observed behavior:
Please observe that Grid.UserAddedRow is not handled, but since we cannot even see the AddNewRow, it is not required for this bug.
public partial class TestForm: Form
{
private readonly DataView _view;
public TestForm()
{
InitializeComponent();
_view = new DataView(LoadTable(true));
_grid.ColumnCount = _view.Table.Columns.Count;
_grid.RowCount = _view.Count;
_grid.AllowAddNewRow = true;
_grid.SelectionMode = VirtualGridSelectionMode.FullRowSelect;
}
static private DataTable LoadTable(bool fill)
{
var table = new DataTable();
table.Columns.Add("Number", typeof(int));
if (fill)
for(int i = 0; i < 20; i++)
table.Rows.Add(i);
return table;
}
#region Windows Form Designer generated code
/// <summary>
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
/// </summary>
private void InitializeComponent()
{
this._grid = new Telerik.WinControls.UI.RadVirtualGrid();
((System.ComponentModel.ISupportInitialize)(this._grid)).BeginInit();
this.SuspendLayout();
//
// _grid
//
this._grid.Dock = System.Windows.Forms.DockStyle.Fill;
this._grid.Location = new System.Drawing.Point(0, 0);
this._grid.MultiSelect = true;
this._grid.Name = "_grid";
this._grid.SelectionMode = Telerik.WinControls.UI.VirtualGridSelectionMode.FullRowSelect;
this._grid.Size = new System.Drawing.Size(800, 450);
this._grid.TabIndex = 0;
this._grid.CellValueNeeded += new Telerik.WinControls.UI.VirtualGridCellValueNeededEventHandler(this._grid_CellValueNeeded);
this._grid.UserDeletedRow += new Telerik.WinControls.UI.VirtualGridRowsEventHandler(this._grid_UserDeletedRow);
//
// TestForm
//
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.ClientSize = new System.Drawing.Size(800, 450);
this.Controls.Add(this._grid);
this.Name = "TestForm";
this.Text = "TestForm";
((System.ComponentModel.ISupportInitialize)(this._grid)).EndInit();
this.ResumeLayout(false);
}
#endregion
private Telerik.WinControls.UI.RadVirtualGrid _grid;
private void _grid_CellValueNeeded(object sender, Telerik.WinControls.UI.VirtualGridCellValueNeededEventArgs e)
{
if (e.ColumnIndex < 0)
return;
if (e.RowIndex < 0)
{
e.FieldName = _view.Table.Columns[e.ColumnIndex].ColumnName;
if (e.RowIndex == RadVirtualGrid.HeaderRowIndex)
e.Value = e.FieldName;
}
else if (e.RowIndex < _view.Count)
{
e.Value = _view[e.RowIndex][e.ColumnIndex];
}
}
private void _grid_UserDeletedRow(object sender, Telerik.WinControls.UI.VirtualGridRowsEventArgs e)
{
var rowIndexes = e.RowIndices.Distinct().OrderByDescending(i => i).ToList(); // Off topic: I have seen duplicate row indexes in this row collection. And unsorted. Is that by design?
if (rowIndexes.Count == _view.Count)
{
_view.Table.Rows.Clear();
}
else
{
foreach(var index in rowIndexes)
_view[index].Delete();
}
_grid.RowCount = _view.Count;
}
}
To reproduce: - Open the attached project. - Unselect Column3 from the list. Workaround: this.radVirtualGrid1.MasterViewInfo.CustomColumns.RemoveAt(0); foreach (VirtualGridRowElement rowElement in this.radVirtualGrid1.VirtualGridElement.TableElement.GetDescendants(delegate(RadElement x) { return x is VirtualGridRowElement; }, TreeTraversalMode.BreadthFirst)) { rowElement.CellContainer.Children.Clear(); }
RadVirtualGrid does not support (nullable) booleans out of the box.
There are several pages to work around this issues, like:
In my humble opinion this should be supported by default. Why?
In my mind I think of how a meeting would have been while designing the RadVirtualGrid.
;-)
Please run the attached sample project and navigate with the left/right arrows as it is demonstrated in the gif file.
The attached gif file illustrates how to reproduce the problem with the Demo application.
To reproduce: void radButton1_Click(object sender, EventArgs e) { this.radVirtualGrid1.CurrentCell = null; } Workaround: class MyRadVirtualGrid : RadVirtualGrid { protected override void CreateChildItems(RadElement parent) { base.CreateChildItems(parent); parent.Children.RemoveAt(0); var field = typeof(RadVirtualGrid).GetField("virtualGridElement", System.Reflection.BindingFlags.NonPublic | System.Reflection.BindingFlags.Instance); var element = new MyVirtualGridElement(); field.SetValue(this,element); parent.Children.Add(element); } } class MyVirtualGridElement : RadVirtualGridElement { protected override Type ThemeEffectiveType { get { return typeof(RadVirtualGridElement); } } protected override bool SetCurrentCell(VirtualGridCellInfo value) { if (value == null) { if (this.IsInEditMode && !this.EndEdit()) { return false; } int row = int.MinValue; VirtualGridViewInfo viewInfo = null; if (this.CurrentCell != null) { row = this.CurrentCell.RowIndex; viewInfo = this.CurrentCell.ViewInfo; } if (this.CurrentCell != null && (value == null || this.CurrentCell.ViewInfo != value.ViewInfo || this.CurrentCell.RowIndex != value.RowIndex)) { VirtualGridRowValidatingEventArgs e = new VirtualGridRowValidatingEventArgs(row, viewInfo); this.OnRowValidating(e); if (e.Cancel) { return false; } } var currentCell = typeof(RadVirtualGridElement).GetField("currentCell", System.Reflection.BindingFlags.NonPublic | System.Reflection.BindingFlags.Instance); currentCell.SetValue(this, value); if (this.CurrentCell != null) { this.EnsureCellVisible(this.CurrentCell.RowIndex, this.CurrentCell.ColumnIndex, this.CurrentCell.ViewInfo); } VirtualGridTableElement tableElement = null; if (this.CurrentCell != null) { tableElement = this.GetTableElement(this.CurrentCell.ViewInfo); } else { tableElement = this.TableElement; } if (tableElement != null) { VirtualGridRowElement rowElement = tableElement.ViewElement.GetRowElement(row); if (rowElement != null) { rowElement.Synchronize(false); } } if (value != null) { tableElement = this.GetTableElement(value.ViewInfo); if (tableElement != null) { VirtualGridRowElement rowElement = tableElement.ViewElement.GetRowElement(value.RowIndex); if (rowElement != null) { rowElement.Synchronize(false); } } } if (viewInfo != null) { VirtualGridRowEventArgs args = new VirtualGridRowEventArgs(row, viewInfo); this.OnRowValidated(args); } this.OnCurrentCellChanged(EventArgs.Empty); return true; } return base.SetCurrentCell(value); } }
To reproduce: - Remove the default padding: private void RadVirtualGrid1_RowExpanding(object sender, VirtualGridRowExpandingEventArgs e) { e.ChildViewInfo.Padding =new Padding(0,0,0,0); } Still some space remains, this can be seen in the demo application as well.
Scenario to cover: the user tries to filter the grid not with each entered symbol but when the value in the filter cell is committed (Enter key is pressed) and the editor is closed. The CellValuePushed event is fired only for data cells and the FilterChanged event is fired with each keystroke but not when the editor is closed. A similar scenario is valid for the new row. There is no suitable event for capturing when a certain cell is updated in the new row as well.
RadVirtualGridElement.Paste does not support pasting into new rows.
I want to override RadVirtualGridElement.Paste to allow to to paste into new rows. Except when I do so, the methods to retrieve information from the clipboard (GetHtmlData/GetTextData/GetCsvData ) are private.
So now I have one request, two solutions:
I was trying to move the NewRow to the bottom of the RadVirtualGrid. I learned that this is not possible. During my attempts I ran into a bug:
Reproduction steps:
Expected behavior:
Observed behavior:
I was trying to move the NewRow to the bottom of the RadVirtualGrid. This is also supported by its big brother RadGridView. I have now learned that this is not supported by RadVirtualGrid.
Hereby my request: Please support this!
I've created a Harmony patch (which works for me); it might help you if you decide to support it:
static class MoveNewRowToBottom
{
[HarmonyPatch(typeof(VirtualGridTableElement), "InvalidatePinnedRows")]
static class VirtualGridTableElement_InvalidatePinnedRows
{
static private bool _isInvalidating;
static private bool Prefix(VirtualGridTableElement __instance)
{
if (_isInvalidating)
return false;
_isInvalidating = true;
__instance.ViewElement.TopPinnedRows.DisposeChildren();
__instance.ViewElement.BottomPinnedRows.DisposeChildren();
var viewInfo = __instance.ViewInfo;
var rowsViewState = __instance.RowsViewState;
var topPinnedItems = rowsViewState.TopPinnedItems;
var bottomPinnedItems = rowsViewState.BottomPinnedItems;
if (viewInfo.ShowFilterRow)
if (!topPinnedItems.Contains(RadVirtualGrid.FilterRowIndex) && !bottomPinnedItems.Contains(RadVirtualGrid.FilterRowIndex))
rowsViewState.SetPinPosition(RadVirtualGrid.FilterRowIndex, PinnedRowPosition.Top);
if (viewInfo.ShowNewRow)
if (!topPinnedItems.Contains(RadVirtualGrid.NewRowIndex) && !bottomPinnedItems.Contains(RadVirtualGrid.NewRowIndex))
rowsViewState.SetPinPosition(RadVirtualGrid.NewRowIndex, PinnedRowPosition.Top);
if (viewInfo.ShowHeaderRow)
if (!topPinnedItems.Contains(RadVirtualGrid.HeaderRowIndex) && !bottomPinnedItems.Contains(RadVirtualGrid.HeaderRowIndex))
rowsViewState.SetPinPosition(RadVirtualGrid.HeaderRowIndex, PinnedRowPosition.Top);
var elementProvider = __instance.RowScroller.ElementProvider;
var topPinnedRows = __instance.ViewElement.TopPinnedRows;
foreach (int topPinnedRow in topPinnedItems.SortTopRowIndexes())
{
VirtualGridRowElement pinnedRow = (VirtualGridRowElement)elementProvider.GetElement(topPinnedRow, null);
topPinnedRows.Children.Add(pinnedRow);
pinnedRow.Attach(topPinnedRow, null);
}
var bottomPinnedRows = __instance.ViewElement.BottomPinnedRows;
foreach (int bottomPinnedRow in bottomPinnedItems.SortBottomRowIndexes())
{
VirtualGridRowElement pinnedRow = (VirtualGridRowElement)elementProvider.GetElement(bottomPinnedRow, null);
bottomPinnedRows.Children.Add(pinnedRow);
pinnedRow.Attach(bottomPinnedRow, null);
}
_isInvalidating = false;
return false;
}
}
static private IEnumerable<int> SortTopRowIndexes(this ReadOnlyCollection<int> topRowIndexes)
{
var specialRowIndex = topRowIndexes.Where(index => index < 0).ToList();
if (specialRowIndex.Contains(RadVirtualGrid.HeaderRowIndex))
yield return RadVirtualGrid.HeaderRowIndex;
if (specialRowIndex.Contains(RadVirtualGrid.NewRowIndex))
yield return RadVirtualGrid.NewRowIndex;
if (specialRowIndex.Contains(RadVirtualGrid.FilterRowIndex))
yield return RadVirtualGrid.FilterRowIndex;
foreach (var index in topRowIndexes.Where(index => index >= 0))
yield return index;
}
static private IEnumerable<int> SortBottomRowIndexes(this ReadOnlyCollection<int> bottomRowIndexes)
{
foreach (var index in bottomRowIndexes.Where(index => index >= 0))
yield return index;
var specialRowIndex = bottomRowIndexes.Where(index => index < 0).ToList();
if (specialRowIndex.Contains(RadVirtualGrid.FilterRowIndex))
yield return RadVirtualGrid.FilterRowIndex;
if (specialRowIndex.Contains(RadVirtualGrid.NewRowIndex))
yield return RadVirtualGrid.NewRowIndex;
if (specialRowIndex.Contains(RadVirtualGrid.HeaderRowIndex))
yield return RadVirtualGrid.HeaderRowIndex;
}
}
Hi,
I have a problem with the expansion of the last row.
After Row Expanding and Row Collapsing the last or second last row, the last row is not visible because it seems that there I some kind of lock on the scrollbar : it doesn’t scroll down neither with the mouse wheel nor with the button so it is not possible to move on the last row.
If instead you scroll up and then down the row became visible again.
In the attached example project.
Regards
Hello, we have found another small bug of the RadVirtualGrid control.
When paging is enabled on child view, one of the component of the paging panel overlap whit is parent.
I attach source code and screenshot.
Thanks in advance.
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; } } }
To reproduce: please refer to the attached gif file. The CellClick is not fired for the child rows that belong to columns that exceed the width of the parent template. Workaround: set the AutoSizeColumnsMode property to Fill. this.radVirtualGrid1.AutoSizeColumnsMode = Telerik.WinControls.UI.VirtualGridAutoSizeColumnsMode.Fill;
It is difficult to replicate the issue and it is not always reproduced. When using the splitter between columns[1] and columns[2] to resize column[1] I found out that releasing the mouse button doesn't cause the splitter to be released, even when clicking on the grid. It seems to work ok once or twice but once it fails then keeps failing. Workaround: private void radVirtualGrid1_MouseUp(object sender, MouseEventArgs e) { if (e.Button == System.Windows.Forms.MouseButtons.Left) { this.radVirtualGrid1.Cursor = Cursors.Default; } }