VirtualQueryableCollectionView inserting issue

11 posts, 0 answers
  1. Petr Šatka
    Petr Šatka avatar
    21 posts
    Member since:
    Mar 2011

    Posted 27 Jun 2011 Link to this post

    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);
    }
  2. Rossen Hristov
    Admin
    Rossen Hristov avatar
    2478 posts

    Posted 28 Jun 2011 Link to this post

    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
  3. DevCraft banner
  4. Petr Šatka
    Petr Šatka avatar
    21 posts
    Member since:
    Mar 2011

    Posted 28 Jun 2011 Link to this post

    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 });
        }
      }
    }
  5. Petr Šatka
    Petr Šatka avatar
    21 posts
    Member since:
    Mar 2011

    Posted 28 Jun 2011 Link to this post

    EDIT : I have changed the sample code.
  6. Rossen Hristov
    Admin
    Rossen Hristov avatar
    2478 posts

    Posted 28 Jun 2011 Link to this post

    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
  7. Petr Šatka
    Petr Šatka avatar
    21 posts
    Member since:
    Mar 2011

    Posted 28 Jun 2011 Link to this post

    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();
    }
  8. Maya
    Admin
    Maya avatar
    4062 posts

    Posted 29 Jun 2011 Link to this post

    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
  9. Petr Šatka
    Petr Šatka avatar
    21 posts
    Member since:
    Mar 2011

    Posted 29 Jun 2011 Link to this post

    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
  10. Petr Šatka
    Petr Šatka avatar
    21 posts
    Member since:
    Mar 2011

    Posted 12 Jul 2011 Link to this post

    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
  11. Maya
    Admin
    Maya avatar
    4062 posts

    Posted 18 Jul 2011 Link to this post

    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!

  12. Petr Šatka
    Petr Šatka avatar
    21 posts
    Member since:
    Mar 2011

    Posted 18 Jul 2011 Link to this post

    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
Back to Top
DevCraft banner