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

Advanced filtering in ScheduleView

8 Answers 147 Views
ScheduleView
This is a migrated thread and some comments may be shown as answers.
Håkan
Top achievements
Rank 1
Håkan asked on 06 Sep 2011, 01:33 PM
Hi,

We use the ScheduleView as a planning and scheduling tool.
We need to do some advanced filtering of the appointments.
Our appointments are also extended with some more properties that we want to filter on.

How would you suggest we do this filtering?
For example we need to filter out like 10 out of 200 employees (Resources) using something like the drop down with checkboxes in Excel.

Can we use the RadDataFilter component somehow?

Regards,
Håkan

8 Answers, 1 is accepted

Sort by
0
Rosi
Telerik team
answered on 07 Sep 2011, 08:28 AM
Hi Håkan,

You can use the predicate AppointmentFilter property of the view definition to implement the task. For more  details please review our Appointment Filtering example here. Although this is an WPF application the code should works for Silverlight too.

Also for filtering of resources you can use our Grouping and Filtering feature as it is shown here.
Regards,
Rosi
the Telerik team

Thank you for being the most amazing .NET community! Your unfailing support is what helps us charge forward! We'd appreciate your vote for Telerik in this year's DevProConnections Awards. We are competing in mind-blowing 20 categories and every vote counts! VOTE for Telerik NOW >>

0
Håkan
Top achievements
Rank 1
answered on 08 Sep 2011, 05:59 AM
Hi,

I have tried to implement the filtering as you pointed me to in the WPF example, but I can't get it to work.

I have a class (TimeScheduleShift) that extends Appointment with some extra properties, for example EmployeeId and ShiftTypeId.
I use employees as resources.

I also have my own filter control that will return a list of ID's which I the set in the SelectedEmployees property.
My view definition is defined with the property 
AppointmentFilter="{Binding AppointmentsFilter}"

Here is my view model:

public class TimeSchedulePlanningViewModel : ViewModelBase
   {
       #region Public properties
 
       private ObservableCollection<TimeScheduleShift> appointments;
       public ObservableCollection<TimeScheduleShift> Appointments
       {
           get { return this.appointments; }
           set
           {
               this.appointments = value;
               this.OnPropertyChanged("Appointments");
           }
       }
 
       private ObservableCollection<Resource> employeeResources = new ObservableCollection<Resource>();
       public ObservableCollection<Resource> EmployeeResources
       {
           get { return this.employeeResources; }
           set { this.employeeResources = value; }
       }
 
       private ResourceTypeCollection employeeResourceTypeCollection = new ResourceTypeCollection();
       public ResourceTypeCollection EmployeeResourceTypes
       {
           get { return this.employeeResourceTypeCollection; }
           private set { this.employeeResourceTypeCollection = value; }
       }
 
       private GroupDescriptionCollection employeeGroupDescriptionCollection = new GroupDescriptionCollection();
       public GroupDescriptionCollection EmployeeGroupDescriptionCollection
       {
           get { return this.employeeGroupDescriptionCollection; }
           set { this.employeeGroupDescriptionCollection = value; }
       }
 
       private List<int> selectedEmployees = new List<int>();
       public List<int> SelectedEmployees
       {
           get { return this.selectedEmployees; }
           set
           {
               this.selectedEmployees = value;
               this.OnPropertyChanged("SelectedEmployees");
               this.OnPropertyChanged("AppointmentsFilter");
           }
       }
 
       private List<int> selectedShiftTypes = new List<int>();
       public List<int> SelectedShiftTypes
       {
           get { return this.selectedShiftTypes; }
           set
           {
               this.selectedShiftTypes = value;
               this.OnPropertyChanged("SelectedShiftTypes");
               this.OnPropertyChanged("AppointmentsFilter");
           }
       }
 
       #endregion
 
       #region Constructor
 
       public TimeSchedulePlanningViewModel()
       {
           this.Appointments = new ObservableCollection<TimeScheduleShift>();
       }
 
       #endregion
 
       #region Setup
 
       public void SetupEmployeeResources()
       {
           ResourceType resourceType = new ResourceType("Employees");
           resourceType.Resources.AddRange(this.EmployeeResources);
           employeeResourceTypeCollection.Add(resourceType);
           employeeGroupDescriptionCollection.Add(new ResourceGroupDescription() { ResourceType = resourceType.Name });
       }
 
       #endregion
 
       #region Filters
 
       public Predicate<TimeScheduleShift> AppointmentsFilter
       {
           get { return this.Filter; }
       }
 
       private bool Filter(IAppointment appointment)
       {
           TimeScheduleShift shift = appointment as TimeScheduleShift;
           return shift != null && this.FilterByEmployee(shift) && this.FilterByShiftType(shift);
       }
 
       private bool FilterByEmployee(TimeScheduleShift shift)
       {
           return this.SelectedEmployees.Count == 0 || this.SelectedEmployees.Contains(shift.EmployeeId);
       }
 
       private bool FilterByShiftType(TimeScheduleShift shift)
       {
           return this.SelectedShiftTypes.Count == 0 || this.SelectedShiftTypes.Contains(shift.ShiftTypeId);
       }
 
       #endregion
   }

When I try to filter, this method is called: 
public Predicate<TimeScheduleShift> AppointmentsFilter

but it never goes further than that, i.e. this method is not called: 
private bool Filter(IAppointment appointment)

I can't figure out why.
Any ideas?

Regards,
Håkan


0
Rosi
Telerik team
answered on 08 Sep 2011, 01:30 PM
Hi Håkan,

I suggest you try with our latest internal build as we introduced a bug that broke this functionality in one of our previous internal builds. The latest internal build should solve the issue. We are sorry for any inconvenience this causes to you.

Regards,
Rosi
the Telerik team

Thank you for being the most amazing .NET community! Your unfailing support is what helps us charge forward! We'd appreciate your vote for Telerik in this year's DevProConnections Awards. We are competing in mind-blowing 20 categories and every vote counts! VOTE for Telerik NOW >>

0
Håkan
Top achievements
Rank 1
answered on 09 Sep 2011, 06:50 AM
But I'm on the released Q2 version now.
Does the bug exist there also?

Regards,
Håkan
0
Rosi
Telerik team
answered on 12 Sep 2011, 06:44 AM
Hello Håkan,

I suggest you open a support thread and send us your example to test it locally. We will debug it and give you with more detailed instructions how to solve the issue.

Greetings,
Rosi
the Telerik team

Thank you for being the most amazing .NET community! Your unfailing support is what helps us charge forward! We'd appreciate your vote for Telerik in this year's DevProConnections Awards. We are competing in mind-blowing 20 categories and every vote counts! VOTE for Telerik NOW >>

0
Håkan
Top achievements
Rank 1
answered on 20 Sep 2011, 08:57 AM
Hi there,

I thinkt it's quite impossible for me to send you a copy, since this is part of a large system with lots of dependant projects.

I did find an exception in Visual Studios Output window when I opened this control though, maybe it can give you some hints?

System.Windows.Data Error: 'MS.Internal.Data.DynamicValueConverter' converter failed to convert value 'System.Predicate`1[Soe.Silverlight.Time.TimeScheduleShift]' (type 'System.Predicate`1[Soe.Silverlight.Time.TimeScheduleShift]'); BindingExpression: Path='AppointmentsFilter' DataItem='Soe.Silverlight.Time.TimeSchedulePlanningViewModel' (HashCode=57263252); target element is 'Telerik.Windows.Controls.TimelineViewDefinition' (Name='null'); target property is 'AppointmentFilter' (type 'System.Predicate`1[Telerik.Windows.Controls.ScheduleView.IAppointment]').. System.InvalidOperationException: Can't convert type System.Predicate`1[Soe.Silverlight.Time.TimeScheduleShift] to type System.Predicate`1[Telerik.Windows.Controls.ScheduleView.IAppointment].
   at MS.Internal.Data.DefaultValueConverter.Create(Type sourceType, Type targetType, Boolean targetToSource)
   at MS.Internal.Data.DynamicValueConverter.EnsureConverter(Type sourceType, Type targetType)
   at MS.Internal.Data.DynamicValueConverter.Convert(Object value, Type targetType, Object parameter, CultureInfo culture)
   at System.Windows.Data.BindingExpression.ConvertToTarget(Object value).
'iexplore.exe' (Silverlight): Loaded 'Anonymously Hosted DynamicMethods Assembly'

TimeScheduleShift is our extended class, that extends Appointment.

Regards,
Håkan
0
Accepted
Rosi
Telerik team
answered on 21 Sep 2011, 09:32 AM
Hello Håkan,

It seems that the problem is related with the value of the property AppointmentsFilter. This property requires a predicate of type IAppointment only.(System.Predicate`1[Telerik.Windows.Controls.ScheduleView.IAppointment]. I suggest you check what is the type of the value that you set to this property as per the stack trace it is System.Predicate`1[Soe.Silverlight.Time.TimeScheduleShift]

Hope this helps.

Greetings,
Rosi
the Telerik team

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

0
Håkan
Top achievements
Rank 1
answered on 30 Sep 2011, 02:32 PM
Yes, 

Changing it from TimeScheduleShift to IAppointment did the trick, thanks!

- Håkan
Tags
ScheduleView
Asked by
Håkan
Top achievements
Rank 1
Answers by
Rosi
Telerik team
Håkan
Top achievements
Rank 1
Share this question
or