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

How to add custom value to GroupHeaderContentTemplate

7 Answers 115 Views
ScheduleView
This is a migrated thread and some comments may be shown as answers.
Kjell
Top achievements
Rank 1
Kjell asked on 19 Jul 2013, 10:12 PM
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.

7 Answers, 1 is accepted

Sort by
0
Yana
Telerik team
answered on 23 Jul 2013, 02:51 PM
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 >>
0
Kjell
Top achievements
Rank 1
answered on 23 Jul 2013, 10:38 PM
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?

0
Yana
Telerik team
answered on 24 Jul 2013, 08:43 AM
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 >>
0
Kjell
Top achievements
Rank 1
answered on 24 Jul 2013, 05:22 PM
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.
0
Yana
Telerik team
answered on 29 Jul 2013, 10:40 AM
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 >>
0
Kjell
Top achievements
Rank 1
answered on 31 Jul 2013, 10:38 PM
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.
0
Yana
Telerik team
answered on 01 Aug 2013, 06:44 AM
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 >>
Tags
ScheduleView
Asked by
Kjell
Top achievements
Rank 1
Answers by
Yana
Telerik team
Kjell
Top achievements
Rank 1
Share this question
or