RadVirtualGrid when using Hierarchy not resizing child view when showing scrollbar

1 Answer 62 Views
VirtualGrid
Vicent
Top achievements
Rank 1
Iron
Vicent asked on 15 Dec 2023, 10:22 AM | edited on 15 Dec 2023, 10:36 AM

I'm trying RadVirtualGrid with Hierarchy but when columns are resized, and needs to show scrollbar, height of child table element is not updated.

 

Example

 

Is this a bug? Can I update it manualy?

 

Other issue I have noticed is: when child column header is wider than parent row, it is not longer resizable:

Example 2

 

This is the code used in this examples:

public partial class Form1 : Form
    {

        private int parentRows = 4;
        private int parentColumns = 4;

        private int childRows = 2;
        private int childColumns = 6;

        public Form1()
        {
            InitializeComponent();

            this.grid.CellValueNeeded += (s, e) =>
            {
                if (e.ViewInfo == this.grid.MasterViewInfo)
                {
                    if (e.ColumnIndex < 0) return;
                    else if (e.RowIndex == RadVirtualGrid.HeaderRowIndex)
                    {
                        e.Value = "HEADER_" + e.ColumnIndex;
                    }

                    else if (e.RowIndex < 0)
                    {
                        e.Value = "FIELD_" + e.ColumnIndex;
                    }

                    else if (e.RowIndex >= 0 && e.RowIndex < parentRows)
                    {
                        e.Value = "Value (" + e.RowIndex + ";" + e.ColumnIndex + ")";
                    }
                }
                else
                {

                    if (e.ColumnIndex < 0) return;
                    else if (e.RowIndex == RadVirtualGrid.HeaderRowIndex)
                    {
                        e.Value = "CHILD_HEADER_" + e.ColumnIndex;
                    }

                    else if (e.RowIndex < 0)
                    {
                        e.Value = "CHILD_FILED_ " + e.ColumnIndex;
                    }

                    else if (e.RowIndex >= 0 && e.RowIndex < childRows)
                    {
                        e.Value = "Child_Value (" + e.RowIndex + ";" + e.ColumnIndex + ")";
                    }

                }
            };

            this.grid.QueryHasChildRows += (s, e) =>
            {
                e.HasChildRows = e.ViewInfo == this.grid.MasterViewInfo && e.RowIndex >= 0 && e.RowIndex < parentRows;
            };

            this.grid.RowExpanding += (s, e) =>
            {
                e.ChildViewInfo.ColumnCount = childColumns;
                e.ChildViewInfo.RowCount = childRows;
            };


            this.grid.RowCount = parentRows;
            this.grid.ColumnCount = parentColumns;
        }
    }

 

1 Answer, 1 is accepted

Sort by
0
Dinko | Tech Support Engineer
Telerik team
answered on 19 Dec 2023, 12:54 PM

Hello Vicent,

Thank you for the provided details. Let me address your scenarios one by one.

  • ScrollBar overlap row.

I was able to observe this behavior. When the horizontal scrollbar appears, it will overlap the data row. This behavior is undesirable. That is why I have logged it in our Feedback Portal on your behalf. What I can suggest as a workaround is to increase the size of the row and decrease the height of the scrollbar. Or you can consider using only one approach depending on which one fits most in your scenario. The scrollbar is part of the control and event if we add padding/margin, the grid won't resize. 

this.radVirtualGrid1.RowExpanded += RadVirtualGrid1_RowExpanded;
this.radVirtualGrid1.RowFormatting += radVirtualGrid1_RowFormatting;

private void RadVirtualGrid1_RowExpanded(object sender, VirtualGridRowExpandedEventArgs e)
{
    // increase row height
    e.ChildViewInfo.MinRowHeight = 40;
}

private void radVirtualGrid1_RowFormatting(object sender, VirtualGridRowElementEventArgs e)
{
    if (e.RowElement.DetailsElement != null)
    {
        //e.RowElement.DetailsElement.Margin = new Padding(0, 0, 0, 20);
        if (e.RowElement.DetailsElement.Children.Count > 0 && e.RowElement.DetailsElement.Children[0] is VirtualGridTableElement table)
        {
            (table.Children[1] as RadScrollBarElement).RadPropertyChanged -= Scroll_RadPropertyChanged;
            (table.Children[1] as RadScrollBarElement).RadPropertyChanged += Scroll_RadPropertyChanged;
            if ((table.Children[1] as RadScrollBarElement).Visibility == ElementVisibility.Visible)
            {
                // reduce scrollbar height
                (table.Children[1] as RadScrollBarElement).MaxSize = new Size(0, 10);
            }
        }
    }
}

  • Column resize outside parent grid

Thank you for the provided steps. Indeed, you can't resize the column when the parent grid is less wide than the child. Also, every element in the child grid which are outside of the parent grid is not active. These elements do not have a hit test and also break other functionalities. For example, you can't sort/filter the column, edit a cell, select a cell/row, etc. This behavior is also logged in our Feedback Portal on your behalf. I have tried different approaches and what I can only suggest as a workaround is to maximize the width of the parent columns. You can set the AutoSizeColumnsMode to Fill. This way the parent columns will take all the available space, thus allowing you to resize the inner child columns with no problems.

 this.radVirtualGrid1.AutoSizeColumnsMode = VirtualGridAutoSizeColumnsMode.Fill;

Thank you again for reporting these behaviors. I have already increased your Telerik Points for bringing them to our attention. You can subscribe to the feedback items so that you can be notified of their status change. I hope that the suggested workarounds will work for you.

Regards,
Dinko | Tech Support Engineer
Progress Telerik

Love the Telerik and Kendo UI products and believe more people should try them? Invite a fellow developer to become a Progress customer and each of you can get a $50 Amazon gift voucher.

Tags
VirtualGrid
Asked by
Vicent
Top achievements
Rank 1
Iron
Answers by
Dinko | Tech Support Engineer
Telerik team
Share this question
or