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

TwoWay Binding IsChecked on a checkbox not working

9 Answers 704 Views
GridView
This is a migrated thread and some comments may be shown as answers.
Mike Gold
Top achievements
Rank 1
Mike Gold asked on 15 Mar 2010, 10:42 PM
Hi Telerik,

I'm using the Q4 release and wondering if this was fixed or perhaps I'm doing something wrong.  If I create a GridViewDataColumn with a checkbox in a cell template,  the two way binding doesn't work coming back from my viewmodel properly.  It notifies the grid I think, but you need to scroll or page back and forth to see the update of the checkbox.   In other words, if I set IsSelected to true in my view model, it doesn't get reflected in the grid unless I scroll up and down or page back and forth.  Then I see the refresh properly.

To better understand the issue

Here is my XAML:

 

 

 

        <telerik:RadGridView Grid.Row="1" x:Name="SearchResultsGrid" ItemsSource="{Binding SearchResults}"  FrozenColumnCount="2" AutoGenerateColumns="False"   
                             HeaderRowStyle="{StaticResource SearchHeaderRowStyle}"   
                             RowStyle="{StaticResource SearchNormalRowStyle}"   
                             AlternateRowStyle="{StaticResource SearchAlternatingRowStyle}"   
                             AlternationCount="2"   
                             RowIndicatorVisibility="Collapsed" 
                             MultipleSelect="True" SelectionChanged="OnRowSelected" 
                                                          ><!--Background="{StaticResource GridViewRowNormalBackground}"--> 
            <telerik:RadGridView.SortDescriptors> 
                <telerikData:SortDescriptor Member="Schema.Name" 
                                   SortDirection="Ascending" /> 
            </telerik:RadGridView.SortDescriptors> 
 
            <telerik:RadGridView.Columns> 
                <telerik:GridViewDataColumn x:Name="CheckBoxColumn" Header="+"  DataMemberBinding="{Binding}" IsReadOnly="True" > 
                    <telerik:GridViewDataColumn.CellTemplate> 
                        <DataTemplate> 
                            <Border BorderThickness="1" BorderBrush="Gray"  DataContext="{Binding}" > 
                                <CheckBox Style="{StaticResource CheckBox.Standard}" IsChecked="{Binding IsSelected, Mode=TwoWay}" /> 
                             </Border> 
                        </DataTemplate>          
                    </telerik:GridViewDataColumn.CellTemplate> 
                </telerik:GridViewDataColumn> 
 



Here is my view model

 

        private bool isSelected;  
 
        public bool IsSelected  
        {  
            get { return isSelected; }  
            set { isSelected = value;  
 
                PropertyChanged.Raise(this, "IsSelected");  
 
            }  
        }  
 

9 Answers, 1 is accepted

Sort by
0
Vlad
Telerik team
answered on 16 Mar 2010, 07:29 AM
Hello Mike,

We don't have Q4 release for more than three years - can you post the exact version of the grid assembly?

Best wishes,
Vlad
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
Mike Gold
Top achievements
Rank 1
answered on 16 Mar 2010, 03:40 PM
Thanks Vlad,

The Telerik.Windows.Controls.GridView.dll is showing up as

Product Version 2009.3.1127.1030,    Copyright 2008, size 802K 

Best Regards,

-Mike
0
Vlad
Telerik team
answered on 16 Mar 2010, 03:51 PM
Hello Mike,

This version is internal build of Q3 2009 - please try our latest service pack Q3 SP2 (2009.3.1314.1030), our latest build, or even our Q1 2010.

Regards,
Vlad
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
NS
Top achievements
Rank 1
answered on 15 Apr 2010, 02:40 PM
Hi,
Is this confirmed as fixed in Q1 2010 ?

I'm using Q1 2010 but the following code still doesn't work. (isChange is a boolean and is updated trough TwoWay, but the checkbox doesn't get checked)

 <telerikGridView:GridViewDataColumn Header="Change Data" DataMemberBinding="{Binding isChange, Mode=TwoWay}">  
</telerikGridView:GridViewDataColumn> 

Regards,
Nicolas
0
Vlad
Telerik team
answered on 15 Apr 2010, 02:47 PM
Hello Nicolas,

Can you verify if your objects implements properly INotifyPropertyChanged?

Greetings,
Vlad
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
NS
Top achievements
Rank 1
answered on 15 Apr 2010, 02:55 PM
Yes,
The object implements INotifyPropertyChanged

 bool _isChange;  
        public bool isChange  
        {  
            get  
            {  
                return _isChange;  
            }  
            set  
            {  
                _isChange = value;  
                OnPropertyChanged("isChange");  
            }  
        }  
 
          
          
 
        #region INotifyPropertyChanged Members  
 
        private void OnPropertyChanged(string propertyName)  
        {  
            if (PropertyChanged != null)  
            {  
                PropertyChanged(this, new PropertyChangedEventArgs(propertyName));  
            }  
        }  
 
        public event PropertyChangedEventHandler PropertyChanged;  
 
        #endregion 

If I debug, I can cleary see that the boolean is changed. However it is not reflected on the checkbox in the column.
0
Vlad
Telerik team
answered on 15 Apr 2010, 03:06 PM
Hello,

I've just tried this using our Q1 2010 binaries however the grid worked as expected. You can check the attached project for reference.

Kind regards,
Vlad
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
NS
Top achievements
Rank 1
answered on 15 Apr 2010, 03:11 PM
Thank you Vlad.

I figured out the (silly) problem. I forget to add the : INotifyPropertyChanged text next to my class.

This is a result of working weeks and weeks only with WCF generated classes where you don't have to think about such things.

Adding a bool in a custom class in the SL frontend app caused my frustration :-)

Thanks,
Nicolas
0
Rajesh
Top achievements
Rank 1
answered on 29 May 2012, 08:32 AM
Hi Vlad,

i have gone through your attachment it was simply awesome and thanks.
when i click on button fine OnPropertyChanged property is getting fired.
but when i click on check box on the client side(while running) OnPropertyChanged property should get fired(which is what my reqmnt) for that i used CellEditEnded event but im not getting the expected result.

ok let me put my question in this way.. how can i do make OnPropertyChanged  fired on click of check box during runtime?
could you please let me know how to make it editable on client side(which should get effect in the back end)

Please try to reply me as soon as you can.
Thanks in advance.

Regards,
Rajesh KS
Tags
GridView
Asked by
Mike Gold
Top achievements
Rank 1
Answers by
Vlad
Telerik team
Mike Gold
Top achievements
Rank 1
NS
Top achievements
Rank 1
Rajesh
Top achievements
Rank 1
Share this question
or