Resource template not updating

4 posts, 1 answers
  1. Håkan
    Håkan avatar
    183 posts
    Member since:
    May 2011

    Posted 19 Oct 2011 Link to this post

    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




  2. Answer
    Rosi
    Admin
    Rosi avatar
    2527 posts

    Posted 20 Oct 2011 Link to this post

    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 >>

  3. DevCraft banner
  4. Håkan
    Håkan avatar
    183 posts
    Member since:
    May 2011

    Posted 20 Oct 2011 Link to this post

    Great!

    That worked just fine, thanks.

    - Håkan
  5. Cliff McManus
    Cliff McManus avatar
    32 posts
    Member since:
    Mar 2011

    Posted 21 Apr 2013 Link to this post

    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.
Back to Top