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

Rebind is must to reflect changes?

2 Answers 161 Views
GridView
This is a migrated thread and some comments may be shown as answers.
ENTERPRISE INTERNATIONAL SAS
Top achievements
Rank 1
ENTERPRISE INTERNATIONAL SAS asked on 13 Sep 2010, 03:28 PM

Hi!

I have a radgridview readonly = true bounded to a DataTable datasource DataContext. Also I have a details panel with textboxes binding like ElementName=grdGridConsulta, Path=Selected.Column, Mode=TwoWay, UpdateSourceTrigger=Explicit.

To Insert a new row and put textBoxes empty I had to do following:

grdGridConsulta.IsReadOnly = false;
grdGridConsulta.BeginInsert();
grdGridConsulta.IsReadOnly = true;
 

this add a new row to the grid and automatically blank every textboxes and set isReadOnly=true again. I put text on textboxes and next save changes, so, I do like this txtID.GetBindingExpression(TextBox.TextProperty).UpdateSource(); when this happen, grdGridConsulta source doesn't reflect changes from target, but if I add this code line - grdGridConsulta.Rebind(); - grdGridConsulta reflects changes from target. Is it necessary Rebind to accomplish the update???

thanks

P.D: please, I left waiting for an older question not answered not even to know answer is not known.

2 Answers, 1 is accepted

Sort by
0
Accepted
Maya
Telerik team
answered on 14 Sep 2010, 10:00 AM
Hi Ramiro,

The reason that the changes are not immediately reflected in the grid is that when being in edit-mode the DataRowView does not raise the PropertyChanged event. Thus the RadGridView is not instantly notified for the modification and does not update its UI. 
Possible approach may be the one you have encountered - to use Rebind() method. Another way may be to use a Dispatcher and CommitNew() item in the Items Collection.

private void Button_Click(object sender, RoutedEventArgs e)
{
    this.clubsGrid.IsReadOnly = false;
    this.clubsGrid.BeginInsert();
    this.clubsGrid.IsReadOnly = true;
 
    this.Dispatcher.BeginInvoke(new Action(() =>
    {
        this.clubsGrid.Items.CommitNew();
 
    }), System.Windows.Threading.DispatcherPriority.ApplicationIdle, null);        
}

However, in this case you will not be able to cancel the insertion of a new item by double-pressing the "Esc" button.

 

Greetings,
Maya
the Telerik team
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
0
ENTERPRISE INTERNATIONAL SAS
Top achievements
Rank 1
answered on 14 Sep 2010, 02:46 PM
Thanks very much
Tags
GridView
Asked by
ENTERPRISE INTERNATIONAL SAS
Top achievements
Rank 1
Answers by
Maya
Telerik team
ENTERPRISE INTERNATIONAL SAS
Top achievements
Rank 1
Share this question
or