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

Relocating record after grid refresh

3 Answers 78 Views
GridView
This is a migrated thread and some comments may be shown as answers.
Sid
Top achievements
Rank 1
Sid asked on 23 Sep 2009, 07:29 PM
I apologize if this is covered somewhere else but I have been unable to find it so far.  I'm trying to "sync" a detail screen with a Telerik gridview.  The user will edit the information on the detail screen and then save.  I want the save process to update the grid information but I want to be able to return to the record being edited.  This is a multi-user scenario so there is no guarantee that a record would return in the same position so I'm trying to come up with a way to "Find" the right record to fill the SelectedItem property.  I would like to be able to utilize the data's primary key to search the grid and selected that record, is this possible?  I've been looking at the FindRecord method but without success.

Thanks,
-Sid Meyers.

3 Answers, 1 is accepted

Sort by
0
Stefan Dobrev
Telerik team
answered on 25 Sep 2009, 11:49 AM
Hi Sid,

You can use the Items property of RadGridView and search for the edited item there using the Contains() name. However if you want the grid view to update automatically you can implement INotifyPropertyChanged on your objects. If you don't want to do this you can call the Rebind() method which will rebind the grid view.

Hope this help.

Greetings,
Stefan Dobrev
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
Sid
Top achievements
Rank 1
answered on 25 Sep 2009, 03:05 PM
Stefan,

I've got a custom business object that is bound on my details tab and a separate business object which is used to populate the grid on a separate list tab (basically a smaller subset view/stored procedure).  So my save process updates the database and I am doing the rebind already but I'm looking to "Select" the record that the user was working on.  The Contains() only returns a boolean as far as I can tell.  I need to find the record and select it.  If you've got any examples or samples of the Gridview search/find that would be extremely helpful.  Again, what I'd like to do is to be able to feed the Primary Key back to the grid to find and select the appropriate record.

Thanks,
-Sid.
0
Stefan Dobrev
Telerik team
answered on 01 Oct 2009, 07:59 AM
Hello Sid,

You can foreach Items property and find out the item you need. When you find it you can set it to the SelectedItem of the RadGridView. Here is a sample code:

private MyItem GetItemByID(int itemID) 
  foreach (MyItem item in this.RadGridView.Items) 
  { 
    if (item.ID == itemID) 
    { 
      return item; 
    } 
  } 
   
  return null
 
... 
 
this.RadGridView.SelectedItem = GetItemByID(10); 


Sincerely yours,
Stefan Dobrev
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
Sid
Top achievements
Rank 1
Answers by
Stefan Dobrev
Telerik team
Sid
Top achievements
Rank 1
Share this question
or