Dear Community,
We are implementing data virtualization concept in our RadGrid. Things are working fine to a lot of extent sorting and filtering. They are not working on RadGrid. We are NOT using MVVM for now and thus all our code is in code behind file only. Below is the code snippets of various parts of our application.
XAML file
We have three columns in our grid including one template columns.
XAML.cs file
Employee.cs
Most of the code above has been taken from telerik demos code downloaded whenever you install Rad controls.
Shiva
We are implementing data virtualization concept in our RadGrid. Things are working fine to a lot of extent sorting and filtering. They are not working on RadGrid. We are NOT using MVVM for now and thus all our code is in code behind file only. Below is the code snippets of various parts of our application.
XAML file
<
telerik:RadGridView
x:Name
=
"gridVirtual"
ItemsSource
=
"{Binding Employees}"
AutoGenerateColumns
=
"False"
CanUserFreezeColumns
=
"False"
Width
=
"635"
MinHeight
=
"386"
MaxHeight
=
"500"
RowIndicatorVisibility
=
"Collapsed"
ShowGroupPanel
=
"False"
SelectionMode
=
"Single"
SelectionUnit
=
"Cell"
>
<
telerik:RadGridView.Columns
>
<
telerik:GridViewDataColumn
Header
=
"ID"
DataMemberBinding
=
"{Binding ID, Mode=TwoWay}"
ShowDistinctFilters
=
"False"
IsReadOnly
=
"True"
/>
<
telerik:GridViewDataColumn
Header
=
"Name"
DataMemberBinding
=
"{Binding Name, Mode=TwoWay}"
ShowDistinctFilters
=
"False"
IsReadOnly
=
"False"
/>
<
telerik:GridViewDataColumn
DataMemberBinding
=
"{Binding Age, Mode=TwoWay}"
Header
=
"Editable Age"
IsReadOnly
=
"True"
ShowDistinctFilters
=
"False"
>
<
telerik:GridViewDataColumn.CellTemplate
>
<
DataTemplate
>
<
TextBox
Text
=
"{Binding Age, Mode=TwoWay}"
/>
</
DataTemplate
>
</
telerik:GridViewDataColumn.CellTemplate
>
</
telerik:GridViewDataColumn
>
</
telerik:RadGridView.Columns
>
</
telerik:RadGridView
>
We have three columns in our grid including one template columns.
XAML.cs file
public partial class VirtualScrolling_WithoutMVVM : UserControl
{
VirtualQueryableCollectionView _Employees;
List<
Employee
> lstEmployee = null;
public VirtualScrolling_WithoutMVVM()
{
InitializeComponent();
GenerateData();
gridVirtual.ItemsSource = Employees;
}
public VirtualQueryableCollectionView Employees
{
get
{
if (_Employees == null)
{
_Employees = new VirtualQueryableCollectionView();
_Employees.VirtualItemCount = lstEmployee.Count();
_Employees.LoadSize = 10;
var abc = _Employees.FilterDescriptors;
_Employees.FilterDescriptors.CollectionChanged += FilterDescriptorsChanged;
_Employees.ItemsLoading += Customers_ItemsLoading;
}
return _Employees;
}
private set
{
if (this._Employees != value)
{
_Employees.ItemsLoading -= Customers_ItemsLoading;
this._Employees = value;
}
}
}
void FilterDescriptorsChanged(object sender, System.Collections.Specialized.NotifyCollectionChangedEventArgs e)
{
Employees.VirtualItemCount = lstEmployee.Count();
}
void Customers_ItemsLoading(object sender, VirtualQueryableCollectionViewItemsLoadingEventArgs e)
{
_Employees.Load(e.StartIndex, lstEmployee.Skip(e.StartIndex).Take(e.ItemCount));
}
public List<
Employee
> GenerateData()
{
lstEmployee = new List<
Employee
>();
for (int i = 0; i < 500; i++)
{
lstEmployee.Add(new Employee() { ID = i, Name = "Employee - " + i.ToString(), Age=i*10 });
}
return lstEmployee;
}
}
Employee.cs
public class Employee
{
public int ID { get; set; }
public string Name { get; set; }
public int Age { get; set; }
}
Most of the code above has been taken from telerik demos code downloaded whenever you install Rad controls.
What problems are we facing?
- When we click on column headers to sort the data, it doesn't sort.
- Filtering is also not working at all.
It would be great if you could please share your comments with us and help us deal with this issue.
Regards,Shiva