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
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
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?
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
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.
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:
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:
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.
George
the Telerik team
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.
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
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.
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 >>