Appointment Filter is not working for ActiveViewDefinitionIndex=0

7 posts, 0 answers
  1. Louis
    Louis avatar
    3 posts
    Member since:
    Oct 2012

    Posted 02 Nov 2012 Link to this post

    Hi,
    I am using RadScheduleView for Calendar type implementation.
    I  implemented filter that works fine for all ViewDefinitions except the ViewDefinition which is first on the NavigationHeader or in other words the ViewDefinition at Index=0 is not performing Filter.

    Example:-
    Below is the definition of RadSchedulerView that I am using.

          <telerik:RadScheduleView  Name="xRadScheduleView" 
                                    AppointmentsSource="{Binding Appointments}"
                                    ResourceTypesSource="{Binding ResourceTypeCollection, Mode=TwoWay}" 
                                    GroupDescriptionsSource="{Binding GroupDescriptions}"
                                    MinAppointmentHeight="60" 
                                    NavigationHeaderVisibility="Visible" 
                                    SpecialSlotStyleSelector="{StaticResource SpecialSlotStyleSelector}"
                                    SpecialSlotsSource="{Binding SpecialSlots}"
                                    ShowCurrentTimeIndicator="True"
                                    CurrentTimeIndicatorStyle="{StaticResource CurrentTimeIndicatorStyleCustom}"
                                    CurrentDate="{Binding CurrentDate, Mode=TwoWay}"
                                    Grid.Row="1" 
                                    VerticalScrollBarVisibility="Auto"
                                    VerticalAlignment="Stretch" 
                                    SelectedSlot="{Binding SelectedSlot, Mode=TwoWay}"
                                    SelectedAppointment="{Binding SelectedAppointment, Mode=TwoWay}"
                                    HorizontalScrollBarVisibility="Visible" >
    <telerik:RadScheduleView.DragDropBehavior>
              <Helper:AppointmentDragDropConditionalBehavior/>
    </telerik:RadScheduleView.DragDropBehavior>
    <telerik:RadScheduleView.ViewDefinitions>
              <telerik:TimelineViewDefinition AppointmentFilter="{Binding FilterValue}"/>
              <telerik:MonthViewDefinition AppointmentFilter="{Binding FilterValue}"/>
              <telerik:WeekViewDefinition AppointmentFilter="{Binding FilterValue}"/>
              <telerik:DayViewDefinition AppointmentFilter="{Binding FilterValue}" />
            </telerik:RadScheduleView.ViewDefinitions>
    </telerik:RadScheduleView>


    Below are the view definitions .

    <telerik:RadScheduleView.ViewDefinitions>
              <telerik:TimelineViewDefinition AppointmentFilter="{Binding FilterValue}"/>
              <telerik:MonthViewDefinition AppointmentFilter="{Binding FilterValue}"/>
              <telerik:WeekViewDefinition AppointmentFilter="{Binding FilterValue}"/>
              <telerik:DayViewDefinition AppointmentFilter="{Binding FilterValue}" />
    </telerik:RadScheduleView.ViewDefinitions>

    The FilterValue is a property in my ViewModel. Some terminology to understand code.
    1. AppointmentBase is Custom Appointment derived from Appointment class as suggested in your Help website.
    2. Process is Resource derived from Resource class as suggested in your Help website.
    3. CheckedProcesses is the local property which is List of Process ( Resource)

    public Predicate<IAppointment> FilterValue
    {
      get
      {
        return Filter;
      }
    }
    public bool Filter(IAppointment appt)
    {
      if (SelectedProcess == null && !SelectAllProcesses)
        return false;
      if (SelectAllProcesses)
        return true;
      AppointmentBase app = appt as AppointmentBase; //Custom Appointment
      return app != null && FilterByProcess(app);
    }
    public bool FilterByProcess(DZNEAppointmentBase app)
    {
      bool isFiltered = false;
      isFiltered = this.CheckedProcesses.Where(s => s.ProcessID.Equals(app.Process.ProcessID)).FirstOrDefault() != null;
      return isFiltered;
    }

    Filtering Scenario:

    1. When all Resources are checked we need to show all Appointment associated with each checked Resource. 
    2. When user uncheck a Resource, all Appointment associated with that Resource should get disappear from Calendar.


    Above scenario works well for all ViewDefinitions  such as Day, Week, Month, Timeline and other Custom View definitions if an only if the ActiveViewDefinitionIndex is not ZERO.

    So, for above view definition list in code snippet, filter is not working for very first view definition i.e. “TimelineViewDefinition”.

     


    I just want to know what setting I am missing or if there are other ways to implement filter.
    Any input will be highly appreciated.

  2. Vladi
    Admin
    Vladi avatar
    744 posts

    Posted 08 Nov 2012 Link to this post

    Hi Louis,

    We tried to reproduce the issue with the code snippets you provided to us but with no success.

    I created and attached a sample project for you showing how to implement resource filtering in RadScheduleView. Give it a try.

    All the best,
    Vladi
    the Telerik team

    Explore the entire Telerik portfolio by downloading Telerik DevCraft Ultimate.

  3. UI for WPF is Visual Studio 2017 Ready
  4. Louis
    Louis avatar
    3 posts
    Member since:
    Oct 2012

    Posted 16 Nov 2012 Link to this post

    Hi Vladi,
    Thanks for your response.

    The attached example demonstrates Group Filtering.
    public Func<object, bool> GroupFilter
        {
          get
          {
            return this.groupFilter;
          }
          set
          {
            this.groupFilter = value;
            this.OnPropertyChanged(() => this.GroupFilter);
          }
        }

    I don't have different groups. I have only on Group but have different Resources.
    I want to filter Appointments on Resources only.
    The same is demonstrated here ( Creating a Custom Resource Filter ) in last Video.

    I implemented filtering as per suggested in Video. And it works fine if and only if the ActiveViewDefinitionIndex!=0.
    For example: If we have 3 views defined in following order:
    0. Month View
    1. Day View
    2. Week View

    So, my current filter implementation will not work for MonthView as it's ActiveViewDefinitionIndex = 0

    I don't know why it is not working on the other values of ActiveViewDefinitionIndex for RadScheduleView.
    Hope, I am able to explain the issue. Please look into image attached.

    Thanks and regards,
    Louis
  5. Yana
    Admin
    Yana avatar
    4554 posts

    Posted 23 Nov 2012 Link to this post

    Hello Louis,

    We were not able to reproduce the described issue, I have attached our test project based on the video. Note that SelectedResource is not set to a default value, so the ScheduleView will not be filtered initially.

    Hope this helps.

    Regards,
    Yana
    the Telerik team

    Explore the entire Telerik portfolio by downloading Telerik DevCraft Ultimate.

  6. Elgan
    Elgan avatar
    9 posts
    Member since:
    Nov 2012

    Posted 06 Dec 2012 Link to this post

    I had this problem...do you still get it? I don't use resources or anything, just appointment filters.

    I discovered it was because WPF was confused over datacontexts when the schedule was in a templated, template... 
    - This is noted at a WPF bug by MS.

    The workaround is a freezable proxy class.

    Let me know if you didnt get it.


  7. Louis
    Louis avatar
    3 posts
    Member since:
    Oct 2012

    Posted 06 Dec 2012 Link to this post

    Thanks Elgan.
    I didn't get the workaround you mentioned.
    I would request you to give some example/code snippet for the guidance.

    Regards,
    Louis
  8. Elgan
    Elgan avatar
    9 posts
    Member since:
    Nov 2012

    Posted 06 Dec 2012 Link to this post

    so..as my scheduleview is in a tileview..,. I create a proxy link like this;


    <telerik:RadTileView.Resources>
        <ViewModel:BindingProxy x:Key="proxy" ScheduleContext="{Binding ScheduleContext}" />
        </telerik:RadTileView.Resources>

    then in my filter, I do this

    <telerik:WeekViewDefinition   AppointmentFilter="{Binding ScheduleContext.FilterValue, Mode=OneWay, Source={StaticResource proxy}}" ShowAllDayArea="True" ShowTimeRuler="False" />
                                            <telerik:DayViewDefinition AppointmentFilter="{Binding ScheduleContext.FilterValue, Mode=OneWay, Source={StaticResource proxy}}" ShowAllDayArea="True" ShowTimeRuler="False"  />
                                            <telerik:MonthViewDefinition AppointmentFilter="{Binding ScheduleContext.FilterValue, Mode=OneWay, Source={StaticResource proxy}}"/>



    then create a proxy class like this;

    public class BindingProxy : Freezable
     {
         #region Overrides of Freezable
     
         protected override Freezable CreateInstanceCore()
         {
             return new BindingProxy();
         }
     
         #endregion
     
         public object ScheduleContext
         {
             get { return (object)GetValue(DataProperty); }
             set { SetValue(DataProperty, value); }
         }
     
         // Using a DependencyProperty as the backing store for Data.  This enables animation, styling, binding, etc...
         public static readonly DependencyProperty DataProperty =
             DependencyProperty.Register("ScheduleContext", typeof(object), typeof(BindingProxy), new UIPropertyMetadata(null));
     }

    Then in my tile view have a property ScheduleContext with is an instance of the viewmodel I want, which has my Filter inside.




Back to Top
UI for WPF is Visual Studio 2017 Ready