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

Change value in row will make it disappear

2 Answers 52 Views
GridView
This is a migrated thread and some comments may be shown as answers.
John
Top achievements
Rank 1
John asked on 09 Mar 2011, 08:40 AM
I have a issue I haven't found any solution for so far and hopefully you can help me. 
I have a GridView that I bind a IEnumerable<MyViewModel> to. I have a few static resources as well to be able to get the 
GridViewComboBoxColumn to work. 


This issue is that when I initially load my data and bind it, it all looks just fine. When I then select a row, edit a value
and then click on an other row, the row with the edited value will disappear. If I reload the data I can see all the rows again,
but this issue will always happen every time I reload and the data is rebounded.

Edit: This will only happen for the changes for the very first row I change values in as well. When that row is gone, I can change the other rows with no issues at all. 

Edit2: This seems to happen when I have a binding to my ViewModel. If I bind it to a Enumerable<Task> directly it seems to not occur. 


<telerik:RadGridView CanUserReorderColumns="False" RowIndicatorVisibility="Collapsed" ScrollViewer.VerticalScrollBarVisibility="Auto"
                                ScrollViewer.HorizontalScrollBarVisibility="Auto" FrozenColumnCount="1" Margin="10" Grid.Row="1" ShowGroupPanel="False"
                                ItemsSource="{Binding MyViewModels}" SelectedItem="{Binding SelectedTask, Mode=TwoWay}"  AutoGenerateColumns="False">
 
           <telerik:RadGridView.Columns>
               <telerik:GridViewDataColumn UniqueName="ProductCode" DataMemberBinding="{Binding Task.ProductCode}" Header="Task (Product Code)" IsGroupable="False"/>
           </telerik:RadGridView.Columns>
</telerik:RadGridView>

My TaskViewModel look like this:

public class MyViewModel: ViewModelBase
{
    public MyViewModel(MyParentViewModel parentViewModel, TaskEntity task)
    {
        ParentViewModel = parentViewModel;
        Task = task;
    }
 
    public MyParentViewModel ParentViewModel { get; private set; }
    public TaskEntity Task { get; private set; }
}

2 Answers, 1 is accepted

Sort by
0
Ivan Ivanov
Telerik team
answered on 14 Mar 2011, 07:11 PM
Hello John,

Unfortunately, I have met some obstacles, while trying to reproduce your issue, having only the information, you have provided. Would you please, sign up for a registered trial license, so you can send us a demo project, reproducing the described issue ?


Sincerely,
Ivan Ivanov
the Telerik team
Registration for Q1 2011 What’s New Webinar Week is now open. Mark your calendar for the week starting March 21st and book your seat for a walk through all the exciting stuff we ship with the new release!
0
John
Top achievements
Rank 1
answered on 16 Mar 2011, 04:46 PM
Hi there! I manage to find a solution for this after quite some time. The reason was this:

Where I create my ViewModel the code was looking like this:
public IList<MyViewModel> MyViewModels
{
    get {
 
        if(Tasks == null)
            return null;
 
        return Tasks.Select(p => new MyViewModel(this, p));
    }
}

However, when I changed it to look like this it solved all my issues:

public IList<MyViewModel> MyViewModels
{
    get {
  
        if(Tasks == null)
            return null;
  
        return Tasks.Select(p => new MyViewModel(this, p)).ToList();
    }
}

I didn't use the ToList, which seems to be the cause of the whole issue. Sorry for taking up your time. 
Tags
GridView
Asked by
John
Top achievements
Rank 1
Answers by
Ivan Ivanov
Telerik team
John
Top achievements
Rank 1
Share this question
or