This is a migrated thread and some comments may be shown as answers.
Could not load ResourceTypes from Collection
11 Answers 91 Views
This is a migrated thread and some comments may be shown as answers.
Steven
Top achievements
Rank 1
Steven asked on 03 Mar 2011, 03:57 AM
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..



11 Answers, 1 is accepted

Sort by
0
Jakkie Esschert van den
Top achievements
Rank 1
answered on 03 Mar 2011, 10:10 AM
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). 
0
Valeri Hristov
Telerik team
answered on 03 Mar 2011, 10:42 AM
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!
0
Jakkie Esschert van den
Top achievements
Rank 1
answered on 03 Mar 2011, 03:15 PM

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?

0
Valeri Hristov
Telerik team
answered on 03 Mar 2011, 03:34 PM
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!
0
Jakkie Esschert van den
Top achievements
Rank 1
answered on 03 Mar 2011, 05:54 PM

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.

0
George
Telerik team
answered on 08 Mar 2011, 11:22 AM
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!
0
Jakkie Esschert van den
Top achievements
Rank 1
answered on 08 Mar 2011, 02:30 PM

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.

0
George
Telerik team
answered on 11 Mar 2011, 02:54 PM
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!
0
Ryan Plemons
Top achievements
Rank 1
answered on 08 Feb 2012, 02:28 AM
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.
0
Ryan
Top achievements
Rank 1
answered on 02 May 2012, 10:19 PM
Anyone? This is a pretty big deal if it isn't.
0
Yana
Telerik team
answered on 08 May 2012, 10:55 AM
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 >>

Asked by
Steven
Top achievements
Rank 1
Answers by
Jakkie Esschert van den
Top achievements
Rank 1
Valeri Hristov
Telerik team
George
Telerik team
Ryan Plemons
Top achievements
Rank 1
Ryan
Top achievements
Rank 1
Yana
Telerik team
Share this question
or