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

Hi-lighting a Grid Row

3 Answers 66 Views
GridView
This is a migrated thread and some comments may be shown as answers.
Jorge Gonzalez
Top achievements
Rank 1
Jorge Gonzalez asked on 05 Jan 2010, 09:56 PM
Hello,
   I am appending an entry to a grid that contains several hundred items. I use ScrollIntoView to scroll the grid to where the item was added but I have not figured out how to hi-light (select) the new entry. The example at this site on how to do this uses constructs that are no longer supported by the latest release. The grid has the SelectAll and UnSelectAll commands so there has to be some command that selects only one row.
Any help would be appreciated.
Thanks

3 Answers, 1 is accepted

Sort by
0
Rossen Hristov
Telerik team
answered on 06 Jan 2010, 12:35 PM
Hi Jorge Gonzalez,

You should set the SelectedItem property of the grid to the data item you want to be selected, in your case the new entry.

For example:

public MainPage()
{
    InitializeComponent();
 
    this.clubsGrid.ItemsSource = Club.GetClubs();
 
    this.clubsGrid.DataLoaded += new System.EventHandler<System.EventArgs>(clubsGrid_DataLoaded);
}
 
void clubsGrid_DataLoaded(object sender, System.EventArgs e)
{
    this.clubsGrid.SelectedItem = ((IEnumerable<Club>)this.clubsGrid.ItemsSource).Where(c => c.Name == "Chelsea").FirstOrDefault();
}

I hope this helps. Let me know if there are problems.

Regards,
Ross
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
Jorge Gonzalez
Top achievements
Rank 1
answered on 06 Jan 2010, 02:54 PM
Thanks Ross,
   That worked. 
I did this:
this.gridname.SelectedItem = this.gridname.Items[<location of the new item I just added>];
0
Jorge Gonzalez
Top achievements
Rank 1
answered on 13 Jan 2010, 07:05 PM
Hello,
    I also had to add this line so the little arrow that points to the current row is set at the current row:

this.gridname.CurrentItem= this.gridname.Items[<location of the new item I just added>];
Tags
GridView
Asked by
Jorge Gonzalez
Top achievements
Rank 1
Answers by
Rossen Hristov
Telerik team
Jorge Gonzalez
Top achievements
Rank 1
Share this question
or