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

How to ensure an Item (row) is visible

11 Answers 470 Views
GridView
This is a migrated thread and some comments may be shown as answers.
Daní
Top achievements
Rank 1
Daní asked on 03 Aug 2009, 03:19 PM
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

11 Answers, 1 is accepted

Sort by
0
Daní
Top achievements
Rank 1
answered on 05 Aug 2009, 04:31 PM
Hi

any word about this topic?
0
Accepted
Milan
Telerik team
answered on 06 Aug 2009, 09:40 PM
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.
0
Daní
Top achievements
Rank 1
answered on 07 Aug 2009, 09:16 AM
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.
0
Rossen Hristov
Telerik team
answered on 07 Aug 2009, 10:14 AM
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.
0
Daní
Top achievements
Rank 1
answered on 07 Aug 2009, 10:24 AM
Thanks Ross,

I'm sure you will.
0
Jax
Top achievements
Rank 2
answered on 09 Oct 2009, 01:06 PM
With the new API, is there a replacement for:

DataGrid.SelectedRecord.ParentGroup.IsExpanded = true;

?
0
Milan
Telerik team
answered on 13 Oct 2009, 03:29 PM
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.
0
devster
Top achievements
Rank 1
answered on 22 Oct 2009, 09:18 AM
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?
0
Milan
Telerik team
answered on 23 Oct 2009, 09:42 AM
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.
0
Jax
Top achievements
Rank 2
answered on 19 Nov 2009, 09:34 AM
Milan - I don't seem to see the "grid.FindGroupByItem()" in the new release.
Has this been implemented?
0
Milan
Telerik team
answered on 24 Nov 2009, 03:48 PM
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.
Tags
GridView
Asked by
Daní
Top achievements
Rank 1
Answers by
Daní
Top achievements
Rank 1
Milan
Telerik team
Rossen Hristov
Telerik team
Jax
Top achievements
Rank 2
devster
Top achievements
Rank 1
Share this question
or