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

[Solved] row validating refresh due to Q2 2011

7 Answers 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.
FENWICK
Top achievements
Rank 1
FENWICK asked on 03 Aug 2011, 04:44 PM
Hi,

I changed my telerik version to Q2 2011 and I found a new bug.

I have a RadGridView bind to an ObservableCollection. I add an element into the collection so a new row is creating and I show a childwindow to fill informations.
When i close my popup, I have validation errors in the grid so that my entity does not...
In the previous version, it's work.
To solve this problem I call the 'Rebind' method and errors disapper.

cs:
ObservableCollection<Checked<Contact>> _contactsList = new ObservableCollection<Checked<Contact>>();
IEnumerable<Checked<Contact>> allContacts = currentActeur.AllContacts.Select(c => new Checked<Contact>() { Value = c, IsChecked = c.IsPrincipal });
          foreach (Checked<Contact> contact in allContacts)
            _contactsList.Add(contact);
          _grid_Contacts.ItemsSource = _contactsList;
 
 private void AddContact_Click(object sender, RoutedEventArgs e)
    {
      var c = new Checked<Contact>()
      {
        Value = new Contact()
          {     
            Adresse = new Adresse(),
            ChoixImage = ImageType.Photo,          
          }
      };
      _contactsList.Add(c);
      _grid_Contacts.SelectedItem = c;
//Navigate to popup
      MainPage.NavigateTo<ContactControl>(c.Value, true, true, 650, 450);
 
      c.Value.Validate();
      c.Value.Adresse.Validate();
}

xaml:
  <tlk:RadGridView x:Name="_grid_Contacts" AutoGenerateColumns="False" IsReadOnly="True"
                        RowIndicatorVisibility="Collapsed" Margin="20,10" >
            <tlk:RadGridView.Columns>
              <!--Principal ?-->
              <tlk:GridViewColumn Header="Principal">
                <tlk:GridViewColumn.CellTemplate>
                  <DataTemplate>
                    <CheckBox Click="ChangeContactPrincipal_Click" IsThreeState="False" IsChecked="{Binding IsChecked, Mode=TwoWay}"
                              IsEnabled="{Binding IsChecked, Converter={StaticResource BooleanInverterConverter}}"
                              Style="{StaticResource CheckBoxStarStyle}" HorizontalAlignment="Center"/>
                  </DataTemplate>
                </tlk:GridViewColumn.CellTemplate>
              </tlk:GridViewColumn>
              <!--Nom-->
              <tlk:GridViewDataColumn DataMemberBinding="{Binding Value.Nom}" Header="Nom" Width="*"/>
              <!--Prénom-->
              <tlk:GridViewDataColumn DataMemberBinding="{Binding Value.Prenom}" Header="Prénom" Width="*"/>
<tlk:GridViewColumn IsResizable="False" Width="50">
                <tlk:GridViewColumn.Header>
                  <!--Add button-->
                  <tlk:RadButton  CornerRadius="5" Click="AddContact_Click"  Margin="2" VerticalAlignment="Center">
                    <Image Source="myProject;component/Images/icons/ajouter.png"
                           ToolTipService.ToolTip="Ajouter un contact" Width="16"/>
                  </tlk:RadButton>
                </tlk:GridViewColumn.Header>
</tlk:GridViewColumn />
</tlk:RadGridView.Columns>
</tlk:RadGridView>

You can show the refresh problem in attached file.

Regards.

7 Answers, 1 is accepted

Sort by
0
Nedyalko Nikolov
Telerik team
answered on 09 Aug 2011, 07:40 AM
Hi Fenwick,

Unfortunately I cannot figure out what causes the problem.
Could you please send me a sample project which I can debug on my side in order to see what is going on?
Thank you in advance.

Regards,
Nedyalko Nikolov
the Telerik team

Explore the entire Telerik portfolio by downloading the Ultimate Collection trial package. Get now >>

0
FENWICK
Top achievements
Rank 1
answered on 09 Aug 2011, 03:15 PM
Hi Nedyalko Nikolov,
 
I have prepare a SandBox and i better diagnosed. The problem occurs when you have a linked entity bind on gridview.
With the attached file you can reproduce the problem.

Click on the link to download project sample : http://dl.free.fr/getfile.pl?file=/GQ0hquQh

Good luck :)
Regards
0
Nedyalko Nikolov
Telerik team
answered on 10 Aug 2011, 02:28 PM
Hi Fenwick,

You can disable the validation in view mode via ValidatesOnDataErrors property of the RadGridView control.

<tlk:RadGridView x:Name="_gridData" AutoGenerateColumns="False" ValidatesOnDataErrors="InEditMode">

This will validate Entity (or any class that implements INotifyDataErrorInfo class only when RadGridView is about to exit edit mode).

Let me know if this doesn't help.

Greetings,
Nedyalko Nikolov
the Telerik team

Explore the entire Telerik portfolio by downloading the Ultimate Collection trial package. Get now >>

0
FENWICK
Top achievements
Rank 1
answered on 10 Aug 2011, 03:55 PM
Hi,

I don't want to disable validation !

In my sample, you can see on the right side the microsoft datagrid and there are no validation problem.
In the previous Telerik version (Q1 2011), no problem also.

In this version, You can see there is a problem because if it calls the Rebind method, validation refreshed

Please fix this bug in the next release.

Regards
0
Nedyalko Nikolov
Telerik team
answered on 16 Aug 2011, 08:15 AM
Hello Fenwick,

The problem comes from the fact that nested properties, does not throw PropertyChanged event on its parent object. This is very critical to RadGridView's validation mechanism since it is listening for BO.PropertyChanged to update its cells. You could easily fix this with a few lines of code:

public Personne()
    {
        this.Adresse = new Adresse();
        this.Adresse.PropertyChanged += new PropertyChangedEventHandler(Adresse_PropertyChanged);
    }
 
    void Adresse_PropertyChanged(object sender, PropertyChangedEventArgs e)
    {
        this.RaisePropertyChanged("Adresse." + e.PropertyName);
    }

We will reconsider our validation mechanism to take into account such scenarios, but I cannot commit with any specific date or release.

Regards,
Nedyalko Nikolov
the Telerik team

Explore the entire Telerik portfolio by downloading the Ultimate Collection trial package. Get now >>

0
FENWICK
Top achievements
Rank 1
answered on 16 Aug 2011, 03:11 PM
Hello,

Thank to your answer. That's work.

I've won any telerik point to this issue ?

bye

0
Nedyalko Nikolov
Telerik team
answered on 19 Aug 2011, 03:30 PM
Hi Fenwick,

I've updated your Telerik points accordingly.
Thank you for feedback.

Greetings,
Nedyalko Nikolov
the Telerik team

Thank you for being the most amazing .NET community! Your unfailing support is what helps us charge forward! We'd appreciate your vote for Telerik in this year's DevProConnections Awards. We are competing in mind-blowing 20 categories and every vote counts! VOTE for Telerik NOW >>

Tags
GridView
Asked by
FENWICK
Top achievements
Rank 1
Answers by
Nedyalko Nikolov
Telerik team
FENWICK
Top achievements
Rank 1
Share this question
or