How to add custom value to GroupHeaderContentTemplate

8 posts, 0 answers
  1. Kjell
    Kjell avatar
    276 posts
    Member since:
    Jun 2010

    Posted 19 Jul 2013 Link to this post

    I have a scheduler which is hardcoded to be a weekly view.  I would like to add a calculated value in the header for each day.  In the attached screenshot, where the word "TEST" is, that's where my value should go.  I stuck that text in there by creating a custom GroupHeaderContentTemplate, but I'm not sure how to make it a dynamic value. 

    My sheduleview is bound to an observable collection of a custom appointment class which inherits ScheduleView.Appointment.   Where does the 'FormattedName' come from, maybe I can just append my value onto that?   The value I'm trying to add is a total duration of the appointments for that day.
  2. Yana
    Admin
    Yana avatar
    4554 posts

    Posted 23 Jul 2013 Link to this post

    Hi Kjell,

    I have attached a sample project which demonstrates how the GroupHeders can be updated dynamically. You can use it as a base and extend it in order to achieve the exact requirement. In the Update() method inside AvailableTimeHelper class you should calculate the total duration of the appointments for that day and set it to Text property.

    I hope this is helpful.

    Regards,
    Yana
    Telerik
    TRY TELERIK'S NEWEST PRODUCT - EQATEC APPLICATION ANALYTICS for SILVERLIGHT.
    Learn what features your users use (or don't use) in your application. Know your audience. Target it better. Develop wisely.
    Sign up for Free application insights >>
  3. DevCraft banner
  4. Kjell
    Kjell avatar
    276 posts
    Member since:
    Jun 2010

    Posted 23 Jul 2013 Link to this post

    Thanks Yana for the project, this is very helpful and I think I'm close to having it working.  Your sample is a little bit above my head please bear with me.  I have a question about this part:

    <local:AvailableTimeHelper Appointments="{Binding Source={StaticResource ViewModel}, Path=Appointments}"

    Date="{Binding RelativeSource={RelativeSource TemplatedParent}, Path=DataContext.Name, Mode=TwoWay}"

    Resource="{Binding RelativeSource={RelativeSource TemplatedParent}, Path=DataContext.ParentGroup, Mode=TwoWay}"

    />


    You set Appointments to Viewmodel, is there a way to just have it grab whatever the source is for the scheduleview automatically?  I am defining the scheduleview AppointmentsSource in the code behind.  Or should I also set AvailableTimeHelper.Appointments in code when I set it for the scheduleview, if so how do I do that?

  5. Yana
    Admin
    Yana avatar
    4554 posts

    Posted 24 Jul 2013 Link to this post

    Hi Kjell,

    If the Appointments is set with code,  it will not  be updated when a new appointment is added and the GroupHeaders will not receive the latest changes. So I would recommend trying to set the AppointmentsSource of the ScheduleView in a ViewModel and use the current approach.

    Regards,
    Yana
    Telerik
    TRY TELERIK'S NEWEST PRODUCT - EQATEC APPLICATION ANALYTICS for SILVERLIGHT.
    Learn what features your users use (or don't use) in your application. Know your audience. Target it better. Develop wisely.
    Sign up for Free application insights >>
  6. Kjell
    Kjell avatar
    276 posts
    Member since:
    Jun 2010

    Posted 24 Jul 2013 Link to this post

    I can't change the binding of the scheduleview at this point.  But I'd still like to take a stab at this customization.  Can you show me how to bind to the AppointmentsSource anyway, and I'll see if I can work around the new appointment issue you pointed out.

    I took a stab in the dark with this:

    Appointments="{Binding RelativeSource={RelativeSource TemplatedParent}, Path=AppointmentsSource}"



    But Appointments was of course null in AvailableTimeHelper.
  7. Yana
    Admin
    Yana avatar
    4554 posts

    Posted 29 Jul 2013 Link to this post

    Hello Kjell,

    You could try binding with ElementName set to the Name of the ScheduleVIew, check the snippet below:

    Appointments="{Binding ElementName=radScheduleView, Path=AppointmentsSource}"

    Hope this helps.

    Regards,
    Yana
    Telerik
    TRY TELERIK'S NEWEST PRODUCT - EQATEC APPLICATION ANALYTICS for SILVERLIGHT.
    Learn what features your users use (or don't use) in your application. Know your audience. Target it better. Develop wisely.
    Sign up for Free application insights >>
  8. Kjell
    Kjell avatar
    276 posts
    Member since:
    Jun 2010

    Posted 31 Jul 2013 Link to this post

    Thanks Yana, as you warned me, appointmentssource didn't really work but it gave me another idea.

    I'm guessing this is not a best practice, but I'll document here just in case it helps someone else.

    I added 7 dependencyproperties to the radScheduleView, one for each day of the week.  I keep them updated in the codebehind.  I also added 7 properties to your helper class to match.  I then use the update method in your helper class to set 'Text' to the appropriate value.  This appears to be working for me, I can add/remove appointments and it's staying updated.
  9. Yana
    Admin
    Yana avatar
    4554 posts

    Posted 01 Aug 2013 Link to this post

    Hello Kjell,

    I'm glad to hear that you've managed to find a suitable solution.

    Regards,
    Yana
    Telerik
    TRY TELERIK'S NEWEST PRODUCT - EQATEC APPLICATION ANALYTICS for SILVERLIGHT.
    Learn what features your users use (or don't use) in your application. Know your audience. Target it better. Develop wisely.
    Sign up for Free application insights >>
Back to Top
DevCraft banner