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

Horizontal scrollbar when using HtmlViewDefinition

2 Answers 10 Views
GridView
This is a migrated thread and some comments may be shown as answers.
John
Top achievements
Rank 1
John asked on 11 Feb 2014, 07:01 PM
On most of my grids the horizontal scroll bar works correctly, but on the ones where I set the ViewDefinition to a HtmlViewDefinition it does not seem to be working.  I force the scrollbar to always show, but it does not let me scroll over to the columns off of the right side of the grid.  The scrollbar only lets me scroll a tiny bit (about half a column) to the right despite there being a dozen or more columns off of the right side of the grid.  No matter how I resize the window the scrollbar "bar" takes up about 98% of the space with about 2% "empty" space. 

Do you have any suggestions on what I can look at that could cause this?

2 Answers, 1 is accepted

Sort by
0
John
Top achievements
Rank 1
answered on 11 Feb 2014, 09:06 PM
Here is how I setup my HtmlViewDefinition:

private HtmlViewDefinition CreateHTMLView( RadGridView gridView )
{
    HtmlViewDefinition htmlView = new HtmlViewDefinition();
    htmlView.RowTemplate.Rows.Add( new RowDefinition() );
    htmlView.RowTemplate.Rows.Add( new RowDefinition() );
 
    foreach( var col in gridView.Columns )
    {
        if( col.Name != null )
        {
            if( col.Name.StartsWith( "Old" ) )
            {
                htmlView.RowTemplate.Rows[0].Cells.Add( new CellDefinition( col.Name ) );
            }
            else if( col.Name.StartsWith( "New" ) )
            {
                htmlView.RowTemplate.Rows[1].Cells.Add( new CellDefinition( col.Name ) );
            }
            else
            {
                htmlView.RowTemplate.Rows[0].Cells.Add( new CellDefinition( col.Name, col.MinWidth, 1, 2 ) );
            }
        }
    }
    return htmlView;
}


0
George
Telerik team
answered on 14 Feb 2014, 01:06 PM
Hello John,

Thank you for contacting us.

I was able to reproduce this issue with HTML View definition. I have logged it in our Feedback Portal. You can find it here. As a workaround you can use the following class:
public class ActionExecuteHelper
{
    #region Singleton
 
    private static ActionExecuteHelper instance;
 
    private static readonly object syncRoot = new object();
 
    public static ActionExecuteHelper Instance
    {
        get
        {
            if (instance == null)
            {
                lock (syncRoot)
                {
                    if (instance == null)
                    {
                        instance = new ActionExecuteHelper();
                    }
                }
            }
 
            return instance;
        }
    }
 
    #endregion
 
    private readonly Timer timer;
 
    public ActionExecuteHelper()
    {
        this.timer = new Timer();
    }
 
    public void ExecuteDelayedAction(Action action, int delayInMilliseconds)
    {
        EventHandler timerTick = null;
 
        timerTick = delegate
        {
            this.timer.Stop();
            this.timer.Tick -= timerTick;
            action.Invoke();
        };
 
        this.timer.Tick += timerTick;
        this.timer.Interval = delayInMilliseconds;
        this.timer.Start();
    }
}

It will allow you to update the maximum value of the scroll bar accordingly:
ActionExecuteHelper.Instance.ExecuteDelayedAction(() =>
    {
        int width = 0;
        foreach (var col in this.Grid.Columns)
        {
            width += col.Width;
        }
 
        this.Grid.TableElement.HScrollBar.Maximum = width - this.Grid.TableElement.HScrollBar.SmallChange - this.Grid.TableElement.RowHeaderColumnWidth;
    }, 500);

I have also added Telerik Points to your account for reporting this issue.

Let me know if you have further questions.

Regards,
George
Telerik

Check out the new Telerik Platform - the only modular platform that combines a rich set of UI tools with powerful cloud services to develop web, hybrid and native apps. Register for the free online keynote and webinar to learn more about the Platform on Wednesday, February 12, 2014 at 11:00 a.m. ET (8:00 a.m. PT).

Tags
GridView
Asked by
John
Top achievements
Rank 1
Answers by
John
Top achievements
Rank 1
George
Telerik team
Share this question
or