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

[Solved] Binding Selected Item to DomainDataSource

1 Answer 203 Views
GridView
This is a migrated thread and some comments may be shown as answers.
This question is locked. New answers and comments are not allowed.
Kirill Prokopenko
Top achievements
Rank 1
Kirill Prokopenko asked on 23 Sep 2009, 08:32 PM
I'm upgrading from the MS Silverlight DataGrid to the RadGridView and I'm running into an issue. The switchover worked fine except the selected item doesn't seem to be triggering bound controls to update.

I have a DomainDataSource that uses RIA Services.  I then have the following bound to the DDS: a RadGridView, a DataPager, a combobox, and several DataForms. With the MS DataGrid whenever I'd select a row ion the grid the form fields and combobox would correspondingly update. This worked in reverse as well: change the selection in the combobox and the selected grid item would change to match.

The issue I'm running in to is that the RadGridView seems to load from the DDS but then changes to the selection in it don't cause the other bound controls to update (nor does this work in reverse when switching the selection in the combobox.)

I looked at the samples and added a PropertyChanged event with the following code:
private void CaseGrid_PropertyChanged(object sender, PropertyChangedEventArgs e) 
{
    if (e.PropertyName == "CurrentItem"
        this._dds.DataContext = this._caseGrid.CurrentItem; 
}

This doesn't seem to work though; the other bound items don't update.  What might I be missing?

1 Answer, 1 is accepted

Sort by
0
Milan
Telerik team
answered on 25 Sep 2009, 04:21 PM
Hello Ibrahim Muckra,

Currently RadGridView is not synchronizing its CurrentItem/SelectedItem properties with the CollectionView that RadGridView is bound to. Thank you for reporting this problem. We will add synchronization support as soon as possible. 

For the time being you can use the following workaround:

public MainPage()     
{     
    InitializeComponent();     
    
    this.DomainDataSource.DataView.CurrentChanged += new EventHandler(DataView_CurrentChanged);     
    this.gridView2.SelectionChanged += new EventHandler<SelectionChangeEventArgs>(gridView2_SelectionChanged);     
}     
    
void gridView2_SelectionChanged(object sender, Telerik.Windows.Controls.SelectionChangeEventArgs e)     
{     
    this.DomainDataSource.DataView.MoveCurrentTo(this.gridView2.CurrentItem);     
}     
    
void DataView_CurrentChanged(object sender, EventArgs e)     
{     
    this.gridView2.SelectedItem = this.DomainDataSource.DataView.CurrentItem;     
    this.gridView2.CurrentItem = this.DomainDataSource.DataView.CurrentItem;     
}   

Luckily the DomainDataSource provides CurrentChanged event that can be used to synchronize SelectedItem and CurrentItem of the grid. Similarly you can use the SelectionChanged event of RadGridView to updated the CurrentItem of the Domain DataSource.

Thank you once again for your constructive feedback. I have updated your Telerik points.

All the best,
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
Kirill Prokopenko
Top achievements
Rank 1
Answers by
Milan
Telerik team
Share this question
or