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

Duplicate Appointments when Filtering

6 Answers 93 Views
ScheduleView
This is a migrated thread and some comments may be shown as answers.
This question is locked. New answers and comments are not allowed.
Aaron
Top achievements
Rank 1
Aaron asked on 18 Jun 2012, 07:46 PM
Hello,

I am getting duplicate appointments when I change the active ViewDefinition by clicking on a Day or Week Header in the RadScheduleView.  I have my ViewDefinitions defined in the following way, where "FilterAppointments" is a public property of my View-Model.

<telerik:RadScheduleView.ViewDefinitions>
    <telerik:MonthViewDefinition Title="Month View" AppointmentFilter="{Binding FilterAppointments}" />
    <telerik:WeekViewDefinition Title="Week View" AppointmentFilter="{Binding FilterAppointments}" />
    <telerik:DayViewDefinition Title="Day View" AppointmentFilter="{Binding FilterAppointments}" />
</telerik:RadScheduleView.ViewDefinitions>


Everything works properly unless I click on a Day or Week Header.  When I click on a header the appointment filter is applied twice and I get a set of two identical appointments for every one appointment I had before.  When I click on one appointment to select it, the duplicate is also selected.

This is the appointment filter property in the View-Model:

public Predicate<IAppointment> FilterAppointments
{
    get
    {
        return this.Filter;
    }
}


And this is the private method "Filter":

private bool Filter(IAppointment appt)
        {
            SqlAppointment appointment = appt as SqlAppointment;
            if (appointment == null)
            {
                return false;
            }
 
            return this.AppointmentClassFilter(appointment) &&
                this.DueClassFilter(appointment) &&
                this.TicklerClassFilter(appointment) &&
                this.HistoryFilter(appointment) &&
                this.ModuleFilter(appointment);
        }


The methods "AppointmentClassFilter", "DueClassFilter", "TicklerClassFilter", "HistoryFilter" and "ModuleFilter" are all private methods of the View-Model.

How can I prevent this from happening?



Thanks,
 - Aaron

6 Answers, 1 is accepted

Sort by
0
Aaron
Top achievements
Rank 1
answered on 18 Jun 2012, 08:11 PM
I would also like to prevent the user from switching ViewDefinitions by clicking on a Day or Week Header.  Could you show me how to do this as well?

Thank you
0
Konstantina
Telerik team
answered on 21 Jun 2012, 11:15 AM
Hi Aaron,

I wasn't able to reproduce the issue you are describing. Attached I am sending you my test project if you could modify it to reproduce the problem and send it back to us. In that way we will be able to isolate the issue and fix it.
As for the GroupHeaders - in order to modify their style you need to get the whole GroupHeaderStyleSelector from the template of the ScheduleView. You could get it from the installation folder of the Telerik components on your machine. Usually this is C://Program Files/Telerik/RadControls for Silverlight Q1 2012/Themes/ . Inside this folder, search the Themes folder to find the ScheduleView.xaml file that corresponds to your theme of choice. Once you have the file you need to replace the GroupHeaderButton control with a suitable control for your scenario. It is part of the GroupHeaderStyleSelector and you can change the base DateTemplate of the styles in the selector. For more information how to work with a GroupHeaderStyleSelector you could refer to this help article.

Kind regards,
Konstantina
the Telerik team
Explore the entire Telerik portfolio by downloading the Ultimate Collection trial package. Get it now >>
0
Aaron
Top achievements
Rank 1
answered on 27 Jun 2012, 05:09 PM
Hi Konstantina,

I haven't been able to reproduce the issue yet, but I found something else.  I didn't mention this in my original post, but if I start in Month view and then click a day header, I'm taken to Week view rather than Day view. (Clicking on a week view header takes me to Week view as expected.)

All I did to reproduce this was reverse the order of the view definitions in the XAML.

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

My order:
<telerik:RadScheduleView.ViewDefinitions>
                    <telerik:MonthViewDefinition AppointmentFilter="{Binding AppoitmentsFilter}" />
                    <telerik:WeekViewDefinition />
                    <telerik:WeekViewDefinition AppointmentFilter="{Binding AppoitmentsFilter}" />
                    <telerik:DayViewDefinition AppointmentFilter="{Binding AppoitmentsFilter}" />
                </telerik:RadScheduleView.ViewDefinitions>

(That is the code from the project which you attached.) There is another interesting point:
1. I run the application with the View Definition order above (Month > Week > Week > Day) and it starts in Month View
2. In Month View, I click a day header and it goes to Week View
3. In Week View, I click a day header and it goes to the next Week View
4. In the second Week View, I click a day header and it goes back to the last Week View

So I can't get to Day View by clicking day headers if I have my view definitions ordered from Month View to Day View.

This isn't a huge issue--I can solve it by reversing our View Definition order--but our legacy application has the Month to Day order so it's preferable that we keep that order.


I am still looking into the duplicate appointment issue, and thank you for uploading the working project, by the way.
- Aaron
0
Konstantina
Telerik team
answered on 02 Jul 2012, 03:52 PM
Hello Aaron,

Thank you for reporting this issue.

I have logged it in PITS, you could track its status here.
Please write back here when you are able to reproduce the duplicate appointments issue.
Your Telerik points have been updated for the bug report.

All the best,
Konstantina
the Telerik team
Explore the entire Telerik portfolio by downloading the Ultimate Collection trial package. Get it now >>
0
Aaron
Top achievements
Rank 1
answered on 12 Jul 2012, 04:22 PM
Hello,

Another member of our development team found the problem and posted it here.  Basically what is happening is that when handling the VisibleRangeChanged event using the VisibleRangeChangedCommand, the 'OnExecute' method fires twice.  I believe this was causing appointments that fall in the visible range to be added to the appointment source collection twice.

Here is the XAML (modified from the sample project above):
<telerik:RadScheduleView x:Name="radScheduleView1" AppointmentsSource="{Binding Appointments}"
        ResourceTypesSource="{Binding ResourceTypes}"
                VisibleRangeChangedCommand="{Binding VisibleRangeChangedCommand}"
                VisibleRangeChangedCommandParameter="{Binding Path=VisibleRange, RelativeSource={RelativeSource Self}}">

Note that it only fires twice if the week or day view headers are clicked.  If the view definition buttons are clicked, it fires once.

We are currently using interaction triggers as a workaround.  Here is the XAML for the whole ScheduleView:
<telerik:RadScheduleView AppointmentsSource="{Binding Appointments}"
    ResourceTypesSource="{Binding ResourceTypes}">
    <iny:Interaction.Triggers>
        <iny:EventTrigger EventName="VisibleRangeChanged">
            <ins:CallMethodAction MethodName="OnVisibleRangeChanged" TargetObject="{Binding}"/>
        </iny:EventTrigger>
    </iny:Interaction.Triggers>
    <telerik:RadScheduleView.ViewDefinitions>
        <telerik:MonthViewDefinition AppointmentFilter="{Binding AppoitmentsFilter}" />
        <telerik:WeekViewDefinition AppointmentFilter="{Binding AppoitmentsFilter}" />
        <telerik:DayViewDefinition AppointmentFilter="{Binding AppoitmentsFilter}" />
    </telerik:RadScheduleView.ViewDefinitions>
</telerik:RadScheduleView>

Where the "iny" and "ins" xmlns' are defined as follows.
<UserControl x:Class="SilverlightApplication.MainPage"
    ...
             xmlns:ins="http://schemas.microsoft.com/expression/2010/interactions"
    ...
>

These are the required DLLs:
  1. Microsoft.Expression.Interactions.dll
  2. System.Windows.Interactivity.dll
 
And here is the event handler in the View-Model:
public void OnVisibleRangeChanged(object sender, EventArgs e)
{
    if (!System.ComponentModel.DesignerProperties.IsInDesignTool)
    {
        this.GenerateAppointmentsByDateSpan((sender as RadScheduleView)
            .VisibleRange as DateSpan);
    }
}


The 'interaction trigger' approach seems to be working fine for us.  The OnVisibleRangeChanged event handler only fires once, so we're getting the expected behavior.


Thanks,
Aaron


EDIT: I forgot to mention something.  If you modify the sample project above so that the ScheduleView uses the VisibleRangeChangedCommand, the 'OnExecute' method will fire twice, but you will not see duplicate appointments.  I believe this is due to the way that the appointments are being added to the Appointments collection.  In our application we are using a domain service and the appointments in the visible range are loaded whenever that event fires, and I think that is why we were getting duplicate appointments.
0
Konstantina
Telerik team
answered on 18 Jul 2012, 08:28 AM
Hello,

We were able to observe the issue. It is caused by the fact that when changing the view, also the current date is changed and that fires the command for a second time. We will try to find a solution for this problem for the Q3 2012 release. I have logged it in PITS, so that you could track its status there.

Greetings,
Konstantina
the Telerik team

Explore the entire Telerik portfolio by downloading Telerik DevCraft Ultimate.

Tags
ScheduleView
Asked by
Aaron
Top achievements
Rank 1
Answers by
Aaron
Top achievements
Rank 1
Konstantina
Telerik team
Share this question
or