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

VirtualQueryableCollectionView inserting issue

10 Answers 172 Views
GridView
This is a migrated thread and some comments may be shown as answers.
Petr Šatka
Top achievements
Rank 1
Petr Šatka asked on 27 Jun 2011, 02:07 PM
Hi Telerik.
I can not insert new rows into VirtualQueryableCollectionView. The same code with the WPF GridView works correctly. But Silverlight GridView is replacing the rows instead of inserting.

I attached a screenshot of grids after two inserts. The first grid is Silverlight, the second grid is WPF.

Thank you for your help.

Best regards
Peter

Sample code
Xaml
<Button Content="Insert" Click="Button_Click"/>
<telerik:RadGridView x:Name="rgv1" Grid.Row="1"/>

Code behind
public AppView() {
InitializeComponent();
  var source = new List<int>();
  source.Add(1);
  source.Add(2);
  this.rgv1.ItemsSource = new VirtualQueryableCollectionView(source) { LoadSize = 10 };
}
 
private void Button_Click(object sender, RoutedEventArgs e) {
    ((VirtualQueryableCollectionView)this.rgv1.ItemsSource).Insert(0, 3);
}

10 Answers, 1 is accepted

Sort by
0
Rossen Hristov
Telerik team
answered on 28 Jun 2011, 12:20 PM
Hello Petr Šatka,

Why don't you try inserting in the source collection and not directly in the CQCV?

Also, try making the source collection an ObservableCollection<T> one instead of List<T>.

Greetings,
Ross
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
Petr Šatka
Top achievements
Rank 1
answered on 28 Jun 2011, 02:06 PM
Hello Ross,
I have tried to use the ObservableCollection, but unfortunately it does not work. Gridview does not display the inserted rows.

Best regards
Peter

Sample code
namespace RadControlsSilverlightApp1 {
  public partial class MainPage : UserControl {
    public class TestClass {
      public int Property {
        get;
        set;
      }
    }
 
    ObservableCollection<TestClass> source = new ObservableCollection<TestClass>();
 
    public MainPage() {
      InitializeComponent();
      source.Add(new TestClass() { Property = 1 });
      source.Add(new TestClass() { Property = 2 });
      this.rgv1.ItemsSource = new VirtualQueryableCollectionView(source) { LoadSize = 10 };
    }
 
    private void Button_Click(object sender, RoutedEventArgs e) {
      //((VirtualQueryableCollectionView)this.rgv1.ItemsSource).Insert(0, new TestClass() { Property = 3 });
      source.Insert(0, new TestClass() { Property = 3 });
    }
  }
}
0
Petr Šatka
Top achievements
Rank 1
answered on 28 Jun 2011, 02:17 PM
EDIT : I have changed the sample code.
0
Rossen Hristov
Telerik team
answered on 28 Jun 2011, 02:20 PM
Hello Petr Šatka,

The way VQCV works is that someone has to actually request an item and it will then load it on demand. Can you try calling the Rebind method of RadGridView after you insert the new items?

Greetings,
Ross
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
Petr Šatka
Top achievements
Rank 1
answered on 28 Jun 2011, 02:51 PM
Hello Ross,
With the Rebind() the GridView is replacing rows. As in the first case, Gridview shows the two rows only.

Best regards
Peter

Sample code
private void Button_Click(object sender, RoutedEventArgs e) {
    //((VirtualQueryableCollectionView)this.rgv1.ItemsSource).Insert(0, new TestClass() { Property = 3 });
   source.Insert(0, new TestClass() { Property = 3 });
   rgv1.Rebind();
}
0
Maya
Telerik team
answered on 29 Jun 2011, 01:45 PM
Hi Petr Šatka,

You may insert an item like follows:

private void RadButton_Click(object sender, System.Windows.RoutedEventArgs e)
        {
            source.Insert(0, new Order_Detail() { OrderID = source.Count });
            vqcv.VirtualItemCount = source.Count;
        }

Still, I am sending you a sample project illustrating the suggested approach.
  All the best,
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
Petr Šatka
Top achievements
Rank 1
answered on 29 Jun 2011, 03:16 PM
Thank you Maya, but this solution has a drawback. After changing the VirtualItemCount property vqcv invokes an Event with the NotifyCollectionChangedAction.Reset attribute. This causes a reset of GridView and focus of the current row is lost. This behavior is not user friendly when inserting somewhere in the middle of the large collection. Standard insert into WPF vqcv does not reset the GridView.

Best regards
Peter
0
Petr Šatka
Top achievements
Rank 1
answered on 12 Jul 2011, 04:12 PM
Hi,

Well let me ask differently. Is there a way how to get the same behavior with silverlight RadGridView and VQCV as shown in the video?
http://www.youtube.com/watch?v=d-sc0qZYW28

Thank you for your reply.

Best regards
Petr
0
Maya
Telerik team
answered on 18 Jul 2011, 12:57 PM
Hi Petr Šatka,

Currently, the illustrated requirements cannot be accomplished with VirtualQuerableCollectionView. However, we will consider supporting such a scenario. 
 

Kind regards,
Maya
the Telerik team

Register for the Q2 2011 What's New Webinar Week. Mark your calendar for the week starting July 18th and book your seat for a walk through of all the exciting stuff we will ship with the new release!

0
Petr Šatka
Top achievements
Rank 1
answered on 18 Jul 2011, 05:48 PM
Hi Maya,
Thank you for your reply. However, I have one more question. It is possible to implement a custom virtualized collection? I tried to use a similar solution to this http://www.codeproject.com/KB/WPF/WpfDataVirtualization.aspx, that uses UI virtualization. Unfortunately the RadGridView always iterates through the entire collection. What conditions must my virtualized collection meet to work with the Silverlight RadGridView?

Best regards,
Peter
Tags
GridView
Asked by
Petr Šatka
Top achievements
Rank 1
Answers by
Rossen Hristov
Telerik team
Petr Šatka
Top achievements
Rank 1
Maya
Telerik team
Share this question
or