How to ensure an Item (row) is visible

12 posts, 1 answers
  1. Daní
    Daní avatar
    303 posts
    Member since:
    Feb 2008

    Posted 03 Aug 2009 Link to this post

    I would like to know if is possible to ensure an item's visibility. That means to scroll the control and/or expand a group to ensure that an item in gridview is visible by the user.

    Thanks
  2. Daní
    Daní avatar
    303 posts
    Member since:
    Feb 2008

    Posted 05 Aug 2009 Link to this post

    Hi

    any word about this topic?
  3. DevCraft banner
  4. Answer
    Milan
    Admin
    Milan avatar
    1989 posts

    Posted 06 Aug 2009 Link to this post

    Hello Daní,

    I have created two methods that should help you ensure an item is visible:

    private void BrindIntoView(DataRecord record)  
    {  
        this.ExpandAllParentGroups(record);  
     
        this.Dispatcher.BeginInvoke( new Action(() =>   
            this.RadGridView1.ItemsControl.BringDataItemIntoView(record.Data)));  
    }  
     
    private void ExpandAllParentGroups(Record record)  
    {  
        var currentRecord = record;  
     
        while (currentRecord.ParentGroup != null)  
        {  
            currentRecord.ParentGroup.IsExpanded = true;  
            currentRecord = currentRecord.ParentGroup;  
        }  

    The key method is BringIntoView - it will bring into view a given data record. You can get access to the grid's records by using RadGridView.Records collection or retrieve a record from a data item using RadGridView.FindRecord method.

    Hope this helps.

    Kind regards,
    Milan
    the Telerik team

    Instantly find answers to your questions on the new Telerik Support Portal.
    Check out the tips for optimizing your support resource searches.
  5. Daní
    Daní avatar
    303 posts
    Member since:
    Feb 2008

    Posted 07 Aug 2009 Link to this post

    Thanks Milan,

    It works great... but I'm getting a warning in Visual Studio about Record class is obsolete and will not be longer used.
  6. Rossen Hristov
    Admin
    Rossen Hristov avatar
    2478 posts

    Posted 07 Aug 2009 Link to this post

    Hi Daní,

    We will do our best to provide means (API) for doing the same thing when we obsolete the records API.

    All the best,
    Ross
    the Telerik team

    Instantly find answers to your questions on the new Telerik Support Portal.
    Check out the tips for optimizing your support resource searches.
  7. Daní
    Daní avatar
    303 posts
    Member since:
    Feb 2008

    Posted 07 Aug 2009 Link to this post

    Thanks Ross,

    I'm sure you will.
  8. Jax
    Jax avatar
    30 posts
    Member since:
    Sep 2009

    Posted 09 Oct 2009 Link to this post

    With the new API, is there a replacement for:

    DataGrid.SelectedRecord.ParentGroup.IsExpanded = true;

    ?
  9. Milan
    Admin
    Milan avatar
    1989 posts

    Posted 13 Oct 2009 Link to this post

    Hi Malcolm Jack,

    In Q3 we will introduce several methods that will allow you to do that without using records. For example:

    var group = this.gridView.FindGroupByItem(this.gridView.SelectedItem);
    this.gridView.CollapseGroup(group);
    // or
    this.gridView.ExpandGroup(group);

    If you such functionality is required in the current RadGirdView version (Q2 2009)  we could possibly introduce those methiods with one of our internal build releases.

    Hope this information is helpful.

    Kind regards,
    Milan
    the Telerik team

    Instantly find answers to your questions on the new Telerik Support Portal.
    Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
  10. devster
    devster avatar
    19 posts
    Member since:
    Oct 2009

    Posted 22 Oct 2009 Link to this post

    Using version: 2009 Q2

    A related question, consider this scenario: 
    - ShowGroupPanel set to false
    - used a GroupDescriptor to define one grouping that cannot be modified by the user

    Goal: expand (only) the first group when the data is loaded.

    I tried doing this in the Grouping and Grouped events, but the parentgroups are not set at that time.

    In which event is the parent group set of the first record?
  11. Milan
    Admin
    Milan avatar
    1989 posts

    Posted 23 Oct 2009 Link to this post

    Hi dev,

    You can easily expand groups by using our ExpandGroup method:

    public MainPage()
    {
        InitializeComponent();
     
        this.playersGrid.ItemsSource = Club.GetPlayers();
        this.playersGrid.DataLoaded += new System.EventHandler<System.EventArgs>(playersGrid_DataLoaded);
    }
     
    void playersGrid_DataLoaded(object sender, System.EventArgs e)
    {
        // expand the first group
        this.playersGrid.ExpandGroup(this.playersGrid.Items.Cast<IGroup>().First());
    }

    Hope this helps.

    Regards,
    Milan
    the Telerik team

    Instantly find answers to your questions on the new Telerik Support Portal.
    Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
  12. Jax
    Jax avatar
    30 posts
    Member since:
    Sep 2009

    Posted 19 Nov 2009 Link to this post

    Milan - I don't seem to see the "grid.FindGroupByItem()" in the new release.
    Has this been implemented?
  13. Milan
    Admin
    Milan avatar
    1989 posts

    Posted 24 Nov 2009 Link to this post

    Hello Jax,

    This functionality is implemented but unfortunately the class that contains the methods is still internal. We will try to make this helper class publicly available with our latest internal build this Friday.

    For the time being you could use the file that I have attached to this post. Just add it to your project and you should be able to search for groups.

    private void Button_Click(object sender, System.Windows.RoutedEventArgs e)
    {
        var group = this.playersGrid.Items.OfType<IGroup>().FindGroupByItem(this.playersGrid.Items[0]);
    }


    Greetings,
    Milan
    the Telerik team

    Instantly find answers to your questions on the new Telerik Support Portal.
    Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
Back to Top
DevCraft banner