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
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>.
Ross
the Telerik team
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 });
}
}
}
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
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();
}
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
Best regards
Peter
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
Currently, the illustrated requirements cannot be accomplished with VirtualQuerableCollectionView. However, we will consider supporting such a scenario.
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!
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