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

Resource template not updating

3 Answers 60 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 19 Oct 2011, 11:09 AM
Hi,

I have an extended resource template looking like this:
public class TimeScheduleEmployeeResource : Resource
  {
      private int plannedMinutes;
      public int PlannedMinutes
      {
          get { return plannedMinutes; }
          set { plannedMinutes = value; }
      }
 
      private int workingHoursMinutes;
      public int WorkingHoursMinutes
      {
          get { return workingHoursMinutes; }
          set { workingHoursMinutes = value; }
      }
  }

Then I use a TimelineViewDefinition with resource grouping. My resources are employees.
When I load my data I calculate the total scheduled time and put it in the PlannedMinutes property of the resource.

My resource grouping template looks like this:
<local:CustomOrientedGroupHeaderContentTemplateSelector.VerticalResourceTemplate>
                <DataTemplate>
                    <Grid Width="150">
                        <Grid.RowDefinitions>
                            <RowDefinition Height="*" />
                            <RowDefinition Height="*" />
                        </Grid.RowDefinitions>
                        <Grid.Resources>
                            <Style TargetType="TextBlock" BasedOn="{StaticResource DefaultTextBlock}">
                                <Setter Property="VerticalAlignment" Value="Center" />
                                <Setter Property="TextWrapping" Value="NoWrap" />
                            </Style>
                        </Grid.Resources>
                        <TextBlock Grid.Row="0" Text="{Binding Name}" HorizontalAlignment="Center" Padding="5,3,5,0" />
                        <StackPanel Grid.Row="1" Orientation="Horizontal" HorizontalAlignment="Center" Margin="5,0,5,3">
                            <TextBlock Text="{Binding Name.PlannedMinutes, Converter={StaticResource MinutesToTimeSpanConverter}}" />
                            <TextBlock Text="/" />
                            <TextBlock Text="{Binding Name.WorkingHoursMinutes, Converter={StaticResource MinutesToTimeSpanConverter}}" />
                        </StackPanel>
                    </Grid>
                </DataTemplate>
            </local:CustomOrientedGroupHeaderContentTemplateSelector.VerticalResourceTemplate>

The problem it that the resources (employees) are loaded before the appointments, so the resources are displayed before I have calculated the planned minutes and updated the resources with the correct numbers. So the first time it will display a value of 0.
Then, when I move to another day, I will load up some new appointments. At that time, my resources are updated and will show the values from my previous day.

Is there some method I can call to repaint my resources after I have loaded the appointments?

Regards,
HÃ¥kan




3 Answers, 1 is accepted

Sort by
0
Accepted
Rosi
Telerik team
answered on 20 Oct 2011, 09:12 AM
Hello HÃ¥kan,

You can remove the ResourceType of  TimeScheduleEmployeeResource  from the ResourceTypeSource collection and add it again.This will force the resource headers to redraw themselves.

Kind regards,
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 20 Oct 2011, 09:24 AM
Great!

That worked just fine, thanks.

- HÃ¥kan
0
Cliff McManus
Top achievements
Rank 1
answered on 21 Apr 2013, 05:52 PM
To all having problems where the resource does not update on the UI. This by far is the easiest solution to your problem.
If you simply save the last resource type in your appointment, delete the last resource type and then add it back this will cause the UI to refresh all of the resources on the UI.
Tags
ScheduleView
Asked by
Håkan
Top achievements
Rank 1
Answers by
Rosi
Telerik team
Håkan
Top achievements
Rank 1
Cliff McManus
Top achievements
Rank 1
Share this question
or