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

URGENT : Data Virtualization Issues | No sorting and filtering

4 Answers 133 Views
GridView
This is a migrated thread and some comments may be shown as answers.
Shiva
Top achievements
Rank 1
Shiva asked on 15 Sep 2011, 01:30 PM
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

<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

4 Answers, 1 is accepted

Sort by
0
Vlad
Telerik team
answered on 15 Sep 2011, 01:43 PM
Hello ,

 You've missed to sort/filter your data in ItemsLoading event. Please check our demos for more info!

Greetings,
Vlad
the Telerik team

Explore the entire Telerik portfolio by downloading the Ultimate Collection trial package. Get it now >>

0
Shiva
Top achievements
Rank 1
answered on 15 Sep 2011, 05:24 PM
Dear Vlad,

I had a look at demo's code and did noticed that yiu are applying sorting and filtering in ItemsLoading event. However, the code is using WCF RIA services I guess and I was not able to find its corresponding code in WCF.

I request you to please provide me a code snippet based on my code (which I have provided in this thread) which is appropriate in my scenario.

Looking forward for your positive response as always. :-)

Warm Regards,
Shiva
0
Shiva
Top achievements
Rank 1
answered on 19 Sep 2011, 07:38 AM
Dear Vlad,

May I please have your comments on this? We are not using WCF RIA services in our code so can you please let me know how to apply sorting and filtering in Silverlight?

Waiting for your positive response.

Regards,
Shiva
0
Vlad
Telerik team
answered on 19 Sep 2011, 07:54 AM
Hello,

 We have extension methods for WCF RIA services only. For all other services you will need your own custom filtering/sorting technique - pass the collection Filter/Sort descriptors info to your service method and apply these server side. 

Regards,
Vlad
the Telerik team

Explore the entire Telerik portfolio by downloading the Ultimate Collection trial package. Get it now >>

Tags
GridView
Asked by
Shiva
Top achievements
Rank 1
Answers by
Vlad
Telerik team
Shiva
Top achievements
Rank 1
Share this question
or