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

Load usercontrol dynamicly into AppointmentTemplate

13 Answers 136 Views
Scheduler
This is a migrated thread and some comments may be shown as answers.
Andrew
Top achievements
Rank 1
Veteran
Iron
Andrew asked on 13 May 2013, 07:38 PM

Requirements

RadControls  version

 2012.3.1016.40

.NET version

 4.0

Visual Studio version

 2012

programming language

 c#

browser support

all browsers supported by RadControls


PROJECT DESCRIPTION                                    

I want to dynamically load control into the appointment template at runtime. but I cannot seem to figure it out

here is my markup:
<telerik:RadScheduler runat="server" ID="RadScheduler1" Height="100%" SelectedView="TimelineView" ShowFooter="false" DayStartTime="07:00:00" DayEndTime="18:00:00" FirstDayOfWeek="Sunday" LastDayOfWeek="Saturday" EnableDescriptionField="true" DataSubjectField="Title" DataKeyField="ItemId" DataStartField="StartDate" DataEndField="EndDate" AllowDelete="False" AllowEdit="False" AllowInsert="False" Localization-HeaderTimeline="Week TL" OnTimeSlotCreated="RadScheduler1_TimeSlotCreated" OnNavigationCommand="RadScheduler1_NavigationCommand" OnAppointmentCreated="RadScheduler1_AppointmentCreated" OnAppointmentDataBound="RadScheduler1_AppointmentDataBound">
    <AdvancedForm Modal="true"></AdvancedForm>
    <TimelineView UserSelectable="true" SlotDuration="1" TimeLabelSpan="1" NumberOfSlots="7" GroupingDirection="Horizontal" ColumnHeaderDateFormat="dddd, d" EnableExactTimeRendering="false"></TimelineView>
                 <WekView ColumnHeaderDateFormat="dddd, d" HeaderDateFormat="dddd d" ShowHoursColumn="true" UserSelectable="false"   />
    <MonthView ColumnHeaderDateFormat="dddd" DayHeaderDateFormat="dd" />
    <TimeSlotContextMenuSettings EnableDefault="true" />
    <AppointmentTemplate>
        <asp:PlaceHolder ID="phContent" runat="server" />
    </AppointmentTemplate>
</telerik:RadScheduler>

I need to get the bound dataitem, load the required control based on the dataitem and also bind that data to the control

so my plan was to get the data, load the control, and place it into the placeholder control in the the AppointmentTemplate markup.

I am able to get the data in the 'AppointmentDataBound' event but I cannot seen to get access to the placeholder control, and in the 'AppointmentCreated' event that fires after the 'AppointmentDataBound' it looks like I may have access to the control but not the dataitem.

so I am not sure how to do this.






13 Answers, 1 is accepted

Sort by
0
Plamen
Telerik team
answered on 16 May 2013, 10:07 AM
Hello Andrew,

If you want to add templates dynamically to the AppointmentTemplate you can do it as for example in this KB article.

If you want to get the controls somehow after that you should use AppointmentCreated event instead of AppointmentDataBound as for example it is done in this on-line demo.

Hope this will be helpful.

Greetings,
Plamen
the Telerik team
If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the RadControls for ASP.NET AJAX, subscribe to their blog feed now.
0
Andrew
Top achievements
Rank 1
Veteran
Iron
answered on 16 May 2013, 02:29 PM
thanks for your help,

I implemented the template as in the example but I still do not have access to my original data object that was bound, the dataitem property says it is null, when the data binding event fires in the template class

I need the original bound object.

I don't see why i don't have access to the controls defined in the AppointmentTemplate when 'RadScheduler1_AppointmentDataBound' fires, then I could do what I need to do.

we currently us the infragistics calendar control and that exactly what I do with it, or with a basic grid for that matter.

0
Plamen
Telerik team
answered on 20 May 2013, 12:16 PM
Hi Andrew,
 
I am attaching a sample web page where is implemented on way to set dynamic Appointment Templates.

Please review it and let me know if you have further questions or your scenario is somehow different.

 

All the best,
Plamen
the Telerik team
If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the RadControls for ASP.NET AJAX, subscribe to their blog feed now.
0
Andrew
Top achievements
Rank 1
Veteran
Iron
answered on 21 May 2013, 02:34 PM
the example you sent is the same as what I basically implemented from the first response I got.

this is the problem right here
var placeHolder = (PlaceHolder)sender;
IDataItemContainer aptContainer = (IDataItemContainer)placeHolder.BindingContainer;

IDataItemContainer contains a property called 'DataItem' that has an object of type '{Telerik.Web.UI.Appointment}' this  object has values
for starttime, endtime, etc.... but it is not the object I originally bound to the RadScheduler.

I see the need why you might need a custom data object for processing the appointments but the data object  '{Telerik.Web.UI.Appointment}' does have a dataitem property that I would expect would contain my original data object but it is null. There is a lot of data that I need to retrieve from the data objects that I bound to the RadScheduler.






0
Plamen
Telerik team
answered on 24 May 2013, 12:16 PM
Hi Andrew,

 
Thank you for getting back to us.

You can use Custom Attributes to add other fields from your database as in the updated web page attached. If you do not want to see them in the advanced form you can just set EnableCustomAttributeEditing=false.

Hope this will help you solve the issue. If you have further questions I will be glad to assist  you again.

Regards,
Plamen
Telerik
If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the RadControls for ASP.NET AJAX, subscribe to their blog feed now.
0
Andrew
Top achievements
Rank 1
Veteran
Iron
answered on 24 May 2013, 01:59 PM
ok, thanks

I will give that a try.

Van I ask why don't you just include that original bound data object in the 'Telerik.Web.UI.Appointment' object as there is a dataitem property that is null.

Can you add it as a suggestion.....
0
Plamen
Telerik team
answered on 28 May 2013, 12:16 PM
Hi Andrew,

 
Thank you for the recommendation -I will forward it to our development team for further consideration.

Regards,
Plamen
Telerik
If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the RadControls for ASP.NET AJAX, subscribe to their blog feed now.
0
Andrew
Top achievements
Rank 1
Veteran
Iron
answered on 28 May 2013, 04:30 PM
I was able to do as you suggested, with a few small changes.

I used the Custom Attributes to store the objects id and stored my data collection in a global list before binding.
then in the appointment create event I load my usercontrol into a place holder control and get the id from the custom attribute to find the required object using linq to get the object and bind it to my usercontol.

but I have run into one other small problem, the usercontrols that I load can be of different heights. and the row height looks to be defined by a div with  css class called 'rsWrap' .

Image 1 shows what it looks like with no css changes, image 2 show what it looks like with the following css changes

.rsWrap
{
    height: 75px !important;
    margin-top: 5px !important;
}
 
 
 
.rsApt
{
    height: inherit !important;
    margin-top: 5px !important;
     
    width: 95% !important;
    margin-left: 6px !important;
    margin-right: 6px !important;
}


the problem is that I need the height to be dynamic so it will size to the largest control I load in and collapse if the row is empty.

I am going to guess the only way to so this would be with jquery, do you have any idea how I can do this?

0
Plamen
Telerik team
answered on 31 May 2013, 08:30 AM
Hi Andrew,

 
This scenario is only possible with exact predefined sizes. Unfortunately setting dynamic sizes of the appointments is not supported in RadScheduler. Please excuse us for this limitation of our control.

Hope this will explain the issue.

Regards,
Plamen
Telerik
If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the RadControls for ASP.NET AJAX, subscribe to their blog feed now.
0
Andrew
Top achievements
Rank 1
Veteran
Iron
answered on 04 Jun 2013, 03:00 PM
ok, thanks

maybe you can help with this?

I have been playing with the control height, and when I select the date picker calendar it is getting clipped (see attached pic)
is there anyway to get it to show it correctly?

Andrew Day
 

0
Plamen
Telerik team
answered on 07 Jun 2013, 07:55 AM
Hi Andrew,

 
this is also a known issue in RadScheduler when its height is not enough to show the calendar. the only way to work it around is to use a separate RadCalendar as in the attached web page.

hope this will be helpful.

Regards,
Plamen
Telerik
If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the RadControls for ASP.NET AJAX, subscribe to the blog feed now.
0
Andrew
Top achievements
Rank 1
Veteran
Iron
answered on 10 Jun 2013, 01:48 PM
ok, thanks.

is there a fix, or do you know when we may see a fix
0
Plamen
Telerik team
answered on 10 Jun 2013, 02:28 PM
Hi Andrew,

Unfortunately this issue can not be fixed because it is caused by the designed functionality of RadScheduler. The only workaround is to use external RadCalendar instead of the inbuilt one as in the attached web page.

Regards,
Plamen
Telerik
If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the RadControls for ASP.NET AJAX, subscribe to the blog feed now.
Tags
Scheduler
Asked by
Andrew
Top achievements
Rank 1
Veteran
Iron
Answers by
Plamen
Telerik team
Andrew
Top achievements
Rank 1
Veteran
Iron
Share this question
or