We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. Image for the cookie policy date
close icon

Bring a specific row into view

In our project a Gantt can have hunderds to even a few thousand resources shown as rows.
Is there a way to scroll to a specific row from code, either by index or by the bound item?


4 Replies

NV Nick Verschueren June 4, 2015 09:33 AM UTC

Meanwhile I found the following workaround for this, but I would appreciate a better solution if anybody has one.

public static class GanttControlExtensions
{
  public static void ScrollToItem(this GanttControl gantt, object item)
  {
    gantt.SelectedItems.Clear();
    gantt.SelectedItems.Add(item);
    var idx = gantt.Model.GetRowIndexFromItem(item);
    var border = VisualTreeHelper.GetChild(gantt.GanttGrid, 0);
    var scrollViewer = (ScrollViewer)VisualTreeHelper.GetChild(border, 0);
    scrollViewer.ScrollToVerticalOffset(Math.Max((idx - 1) * gantt.RowHeight, 0));
  }
}


SS Suresh S Syncfusion Team June 4, 2015 01:40 PM UTC

Hi Nick,

We are currently analyzing on any workaround feasibility for requirement. Hence, We will update by tomorrow

Regards,

Suresh S



SS Suresh S Syncfusion Team June 5, 2015 01:08 PM UTC

Hi Nick,

We have analyzed your query and achieved your requirement of bringing specific record in to view. We have prepared a sample based on this, please download from below location,

Let us know in case of any query.

Regards,
Suresh S


Attachment: GridTreeControl_Sample_5a91decc.zip


SS Suresh S Syncfusion Team June 10, 2015 01:03 PM UTC

Hi Nick,

Please ignore our previous update.

We have prepared a sample to bring specific record into view, please download from below location.

CodeSnippet:

RowColumnIndex rowcolumnindex = new RowColumnIndex();

            rowcolumnindex.RowIndex = Convert.ToInt16(txtbox.Text);

            this.GanttControl.GanttGrid.Model.TreeGrid.ScrollInView(rowcolumnindex);

            this.GanttControl.GanttGrid.Model.TreeGrid.CurrentCell.MoveTo(rowcolumnindex);

Note:

In the sample, when the ganttcontrol is loaded, initially a specific row should be selected and then we can input the row index in the user option to bring the record into view.

Please let us know in case of any query.

Regards,

Suresh S


Attachment: GanttControl_6404e168.zip

Loader.
Live Chat Icon For mobile
Up arrow icon