Could not load ResourceTypes from Collection

12 posts, 0 answers
  1. Steven
    Steven avatar
    5 posts
    Member since:
    Sep 2012

    Posted 02 Mar 2011 Link to this post

    Hi,
       I download Tril Version of scheduleView, I could not load ResourceType from Collection.


    Sample Code of ViewModel:

    public List<ResourceTypes> ResourceTypes
    List<ResourceTypes> rType = new List<ResourceTypes>();

    ..add a resourceType
      .. add a Resource


    in XAML use ResourceTypesSource={Binding ResourceTypes}

    it does not work..



  2. Jakkie Esschert van den
    Jakkie Esschert van den avatar
    61 posts
    Member since:
    Sep 2009

    Posted 03 Mar 2011 Link to this post

    I'm seeing similar behavior, however I noticed that when switching between views the resources are loaded. Initially the resources aren't shown, but when I switch from day to e.g. week view they are loaded and displayed (although the names aren't displayed properly). 
  3. DevCraft banner
  4. Valeri Hristov
    Admin
    Valeri Hristov avatar
    2252 posts

    Posted 03 Mar 2011 Link to this post

    Hello,

    In the latest beta release the ResourceTypesSource is of type IEnumerable<IResourceType>. Since the source collection is List<ResourceType> (note this is not the interface), the binding decides that the types are different (and they really are) and sets value null. To workaround the problem, please, use List<IResourceType> instead. The same is for CategoriesSource and TimeMarkersSource.

    In the official release thoes properties will be of type IEnumerable and you will be able to feed them with any IEnumerable, with any generic type parameter.

    Best wishes,
    Valeri Hristov
    the Telerik team
    Registration for Q1 2011 What’s New Webinar Week is now open. Mark your calendar for the week starting March 21st and book your seat for a walk through all the exciting stuff we ship with the new release!
  5. Jakkie Esschert van den
    Jakkie Esschert van den avatar
    61 posts
    Member since:
    Sep 2009

    Posted 03 Mar 2011 Link to this post

    Some testing here seems to show that using ResourceTypeCollection works, but using IList<ResourceType> doesn't work.

    Also it seems I need to set the DataContext after the the ResourceTypes are fully loaded, at least to get my resources shown on the initial display (which is a bit annoying since I get the resources from asynchronous webservice call). Will the official release support using ObservableCollection for the resources list?

  6. Valeri Hristov
    Admin
    Valeri Hristov avatar
    2252 posts

    Posted 03 Mar 2011 Link to this post

    Hello Jakkie,

    ResourceTypeCollection works because it inherits from ObservableCollection<IResource>.

    As far as I can see, we attach CollectionChanged handler on the ResourceTypesSource if it implements INotifyCollectionChanged, so if you add new resource types at runtime the control should update itself. However, it will not update if you add new resource in an existing in the collection resource type at runtime, which I suppose is your scenario. Could you please, provide more information about how do you build the data context, so we might fix the potential bug before the release?

    Regards,
    Valeri Hristov
    the Telerik team
    Registration for Q1 2011 What’s New Webinar Week is now open. Mark your calendar for the week starting March 21st and book your seat for a walk through all the exciting stuff we ship with the new release!
  7. Jakkie Esschert van den
    Jakkie Esschert van den avatar
    61 posts
    Member since:
    Sep 2009

    Posted 03 Mar 2011 Link to this post

    I've uploaded a test project here: http://d6.nl/stuff/ScheduleViewTest.zip

    On the MainPage there are some comments about how setting the datacontext at different points causes different behavior. I also triggered a different bug where a groupheader is not removed correctly.

  8. George
    Admin
    George avatar
    1332 posts

    Posted 08 Mar 2011 Link to this post

    Hi Jakkie,

     
    We took some time to investigate the problem. I would suggest you to add the resource types after you load the resources. For example, the constructor should look like:

    Copy Code
    Copy Code
    public ScheduleModel()
           {
               Resources = new ResourceTypeCollection();
     
               LocationsResource = new ResourceType("Location");
               LocationsResource.AllowMultipleSelection = false;
               LocationsResource.DisplayName = LocalizationManager.GetString("_Location");
     
               LotsResource = new ResourceType("Lot");
               LotsResource.AllowMultipleSelection = false;
               LotsResource.DisplayName = LocalizationManager.GetString("_Lots");
     
               GroupDescriptions = new GroupDescriptionCollection();
               ResourceGroupDescription locationGrp = new ResourceGroupDescription();
               locationGrp.ResourceType = "Location";
               locationGrp.ShowNullGroup = false;
               //locationGrp.GroupNames.Add("");
               GroupDescriptions.Add(locationGrp);
     
               ResourceGroupDescription lotGrp = new ResourceGroupDescription();
               lotGrp.ResourceType = "Lot";
               lotGrp.ShowNullGroup = false;
     
               GroupDescriptions.Add(lotGrp);
     
               Appointments = new ObservableCollection<Allocation>();
           }

    ..and the SetLocations method should look like:


    Copy Code
    Copy Code
    public void SetLocations()
           {
               LocationsResource.Resources.Clear();
               LotsResource.Resources.Clear();
               Resources.Clear();
     
               for (int i = 0; i < 4; i++)
               {
                   Resource res = new Resource("Loc"+i, "Location");
                   LocationsResource.Resources.Add(res);
                   for (int j = 0; j < 3; j++ )
                   {
                       Resource lotRes = new Resource("Lot"+i+"-"+j, "Lot");
                       LotsResource.Resources.Add(lotRes);
                   }
               }
     
               Resources.Add(LocationsResource);
               Resources.Add(LotsResource);
     
               AddAppointments();
               ValueChanged("Locations");
               ValueChanged("Resources");
               ValueChanged("LocationsResource");
               ValueChanged("GroupDescriptions");
           }

    We will consider to change this behavior in our further development. Sorry for any inconvenience caused.


    All the best,
    George
    the Telerik team
    Registration for Q1 2011 What’s New Webinar Week is now open. Mark your calendar for the week starting March 21st and book your seat for a walk through all the exciting stuff we ship with the new release!
  9. Jakkie Esschert van den
    Jakkie Esschert van den avatar
    61 posts
    Member since:
    Sep 2009

    Posted 08 Mar 2011 Link to this post

    That does indeed work. Thanks!

    Edit:

    Well, I was a bit to quick there, it almost works. It does update the Scheduler properly, but fails to remove the date header which was initially visible on the day view. When switching views this header stays visible as well, like the scheduleview lost track of it.

  10. George
    Admin
    George avatar
    1332 posts

    Posted 11 Mar 2011 Link to this post

    Hello,

    The fix for this bug will be included in our 2011 Q1 release next week. Sorry for any inconvenience caused. 

     

    All the best,
    George
    the Telerik team
    Registration for Q1 2011 What’s New Webinar Week is now open. Mark your calendar for the week starting March 21st and book your seat for a walk through all the exciting stuff we ship with the new release!
  11. Ryan Plemons
    Ryan Plemons avatar
    1 posts
    Member since:
    Jan 2006

    Posted 07 Feb 2012 Link to this post

    can you verify this is indeed fixed in the latest code? I am seeing the same issue with the latest code bits installed.

    To be clear, I got this to work by Removing the ResourceTypes from the collection, adding/removing the Resources and then re-adding the ResourceTypes to the collection. the removing/adding is an unnecessary step.
  12. Ryan
    Ryan avatar
    1 posts
    Member since:
    Apr 2011

    Posted 02 May 2012 Link to this post

    Anyone? This is a pretty big deal if it isn't.
  13. Yana
    Admin
    Yana avatar
    4554 posts

    Posted 08 May 2012 Link to this post

    Hi Ryan,

    The bug discussed in the previous posts seems different from your issue. I guess that you're trying to add resources to a certain ResourceType at runtime. If this is the case,  you should really remove and add again the ResourceType from ResourceTypesSource collection of the ScheduleView.

    Actually this is expected behavior as explained in the following help article:
    http://www.telerik.com/help/silverlight/radscheduleview-howto-update-resources.html#Adding_Resources


    Regards,
    Yana
    the Telerik team

    Explore the entire Telerik portfolio by downloading the Ultimate Collection trial package. Get it now >>

Back to Top
DevCraft banner