Data bind Group header

7 posts, 0 answers
  1. Vikas
    Vikas avatar
    64 posts
    Member since:
    May 2014

    Posted 10 Jul 2015 Link to this post

    I am using radscheduleView and i am adding a day with multiple resources. 
    In the attached image i have 2 columns one for each combination of resources. I need to display the number of appointments there are for each day and i am able to do.

    the first column shows the right number (4) but the second column also displays 4 and it should display 0
    i am using mvvm and i have a view model data bin to the RadSchedulView and there is a property on this view model that is data bind to group header template 
    <TextBlock Margin="4,0,0,0" Text="{Binding DataContext.NumberOfAppointments, RelativeSource={RelativeSource Mode=FindAncestor, AncestorType=telerik:RadScheduleView}}"/>

    What i want to do is have a different value for each column. I guess i can use converter and return the value and some how keep track of the column being added.

    but that will not work if user adds or delete an appointment, i need some way to bind the header to a property and then raise the property changed event.

    Thanks

    Vikas

  2. Kalin
    Admin
    Kalin avatar
    1207 posts

    Posted 13 Jul 2015 Link to this post

    Hello Vikas,

    What I can suggest you in order to achieve the desired would be to implement a custom Resource with a custom property that would hold the count of the Appointments currently in the View. You would need to implement the INotifyPropertyChanged interface for the custom Resource:

    public class CustomResource : Resource, INotifyPropertyChanged
    {
        private int appsInView;
     
        public int AppsInView
        {
            get
            {
                return this.appsInView;
            }
     
            set
            {
                if (this.appsInView != value)
                {
                    this.appsInView = value;
                    this.NotifyPropertyChanged("AppsInView");
                }
            }
        }
    ...
    }

    And bind the property in the needed GroupHeader Template as shown below:
    <TextBlock Text="{Binding Name.AppsInView, Mode=TwoWay}" />

    At last you can simply hook to the CollectionChanged event of the Appointments collection and updated the AppsInView property of each Resource correspondingly.

    Hope this will work for you.

    Regards,
    Kalin
    Telerik
    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Feedback Portal and vote to affect the priority of the items
  3. UI for WPF is Visual Studio 2017 Ready
  4. Vikas
    Vikas avatar
    64 posts
    Member since:
    May 2014

    Posted 13 Jul 2015 in reply to Kalin Link to this post

    The problem with creating a new resource just for displaying the appts is that, the resource will appear every where I mean in appt create dialog and every place i will have to put condition to ignore this resource.

    Is there a way to inherit from DateGroupDescription, that way will be able to add a property to that class.

    Vikas

     

    _groupDescriptions.Add(new ResourceGroupDescription() { ResourceType = SchedulingCommon.Constants.DEPARTMENT });
    _groupDescriptions.Add(new ResourceGroupDescription() { ResourceType = SchedulingCommon.Constants.LOCATION });
    _groupDescriptions.Add(new ResourceGroupDescription() { ResourceType = SchedulingCommon.Constants.RESOURCE });
    _groupDescriptions.Add(new DateGroupDescription()); *********** use my custom class instead ***************

     

  5. Kalin
    Admin
    Kalin avatar
    1207 posts

    Posted 16 Jul 2015 Link to this post

    Hello Vikas,

    What I've meant was to replace the used type of Resource with a custom one (in case you are using the default ScheduleView Resource class) and implement that property. If you are already using a custom Resource class you could just add such a logic.

    As for the DateGroupDescription - it is a public class, so you would be able to inherit from and implement a custom property.

    Hope this helps.

    Regards,
    Kalin
    Telerik
    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Feedback Portal and vote to affect the priority of the items
  6. Vikas
    Vikas avatar
    64 posts
    Member since:
    May 2014

    Posted 16 Jul 2015 in reply to Kalin Link to this post

    Yes i am using custom resource that inherits IResource, I can try to add the new Appt# property to the custom resource.

    The problem is that i wan to display the number of appts (in the screen shot in first message) just below the date, In order to do that i have set the data template for Date. But i am not creating multiple instances of DateResource, may be what i need to do is remove the dategroup from the resource _groupDescriptions and add my own date resource

     

    vikas

  7. Kalin
    Admin
    Kalin avatar
    1207 posts

    Posted 21 Jul 2015 Link to this post

    Hi Vikas,

    I can suggest another solution, however it will display the counts in the last resource instead of the Date GroupHeaders. Note that this approach really depends on the whole resources structure - so you would need to know how many levels of resources you have and how many times the very bottom resources appear in order to add a separate property and DataTemplate using that property for each time. Afterwards using ScheduleViewDataTemplateSelector you can check the parent resources of the bottom once and to return the correct Template bound to the correct property of the CustomResource.

    For your convenience I have prepared a sample project demonstrating the exact approach using 2 levels - note the solution is not completely implemented. You would need to also update the properties whenever an Appointment has been removed and whenever the VisibleRange has been changed.

    Hope this solution will help you to achieve the desired.

    Regards,
    Kalin
    Telerik
    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Feedback Portal and vote to affect the priority of the items
  8. Vikas
    Vikas avatar
    64 posts
    Member since:
    May 2014

    Posted 21 Jul 2015 in reply to Kalin Link to this post

    Thanks Kalin,

     I will try this. Vikas

Back to Top
UI for WPF is Visual Studio 2017 Ready