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

Need help on Rad Scheduler in ASP.Net MVC

1 Answer 42 Views
Scheduler
This is a migrated thread and some comments may be shown as answers.
administrator
Top achievements
Rank 1
administrator asked on 01 Apr 2014, 08:24 AM
Hi All,

I'm new to Rad controls and want to integrate Rad Scheduler and I want to use it in a ASP.Net MVC application. Since Rad Scheduler support ASPX view engine, I have configured to work in ASPX view engine.
 My issue is I'm getting following error "DataKeyField, DataSubjectField, DataStartField and DataEndField are required for databinding". I know that I have to give those data but I didn't find any reference on how to provide them in a ASP.Net MVC project. I have refereed "RadScheduler in MVC sample project" in "http://www.telerik.com/support/kb/aspnet-ajax/scheduler/details/radscheduler-in-mvc-sample-project".

  Would be grateful if you can guide me on how to bind scheduler to a database and do the CRUD operations. 

and also I've seen in Telerik documentation the I can use web API. Is that means that I can directly call my controller from the view without going through a web service? Would be grateful if you can guide me on this as well.

Following is my code.

.ASPX

<div style="width: 80%; float: right;">
        <asp:ScriptManager ID="ScriptManager1" runat="server">
   </asp:ScriptManager>
                        <telerik:RadScheduler ID="RadScheduler1" runat="server" ShowHeader="false" TimelineView-SlotDuration="1" EnableDatePicker="true" OverflowBehavior="Expand"
                            SelectedView="TimelineView" AppointmentStyleMode="Default" AllowInsert="true" AllowEdit="true"  ColumnWidth="75px" RowHeight="50px" >
                             <WebServiceSettings Path="" ResourcePopulationMode="ServerSide" UseHttpGet="true" />
                            <AdvancedForm EnableResourceEditing="False" Enabled="false"  />
                            <TimelineView ShowDateHeaders="true" ShowResourceHeaders="false"  ShowInsertArea="false"  />
                            <AppointmentTemplate  >
                                
                                <div>
                                    <%#Eval("Subject") %>
                                </div>
                                <hr />
                                <div>
                                    Assigned to: <strong>
                                        <asp:Label ID="UserLabel" runat="server" Text='<%# Container.Appointment.Resources.GetResourceByType("EmployeeInfo") == null ? "None" : Container.Appointment.Resources.GetResourceByType("EmployeeInfo").Text %>'></asp:Label>
                                    </strong>
                                    
                                </div>
                            </AppointmentTemplate>
                            
                        </telerik:RadScheduler>
                    </div>

 
Controller : ( I have used the Controller in Web API binding (http://www.telerik.com/help/aspnet-ajax/scheduler-web-api-binding.html))

public partial class ResourcePlannerController : Controller
    {
        private JavaScriptSerializer _serializer;
        private JavaScriptSerializer JavaScriptSerializer
        {
            get
            {
                if (_serializer == null)
                {
                    _serializer = new JavaScriptSerializer();
                }

                return _serializer;
            }
        }

        private XmlSchedulerProvider _provider;
        private XmlSchedulerProvider Provider
        {
            get
            {
                if (_provider == null)
                {
                    //_provider = new CustomXmlSchedulerProvider(System.Web.HttpContext.Current.Server.MapPath("~/App_Data/Appointments_Outlook.xml"), true);
                }

                return _provider;
            }
        }

        private WebServiceAppointmentController _controller;
        private WebServiceAppointmentController Controller
        {
            get
            {
                if (_controller == null)
                {
                    _controller = new WebServiceAppointmentController(Provider);
                }

                return _controller;
            }
        }

        [HttpGet]
        public IEnumerable<AppointmentData> GetAppointments(string schedulerInfo)
        {
            return null;// return Controller.GetAppointments(JavaScriptSerializer.Deserialize<MySchedulerInfo>(schedulerInfo));
        }

        [HttpPost]
        public IEnumerable<AppointmentData> InsertAppointment(WebApiData data)
        {
            return Controller.InsertAppointment(data.SchedulerInfo, data.AppointmentData);
        }

        [HttpPut]
        public IEnumerable<AppointmentData> UpdateAppointment(WebApiData data)
        {

            return Controller.UpdateAppointment(data.SchedulerInfo, data.AppointmentData);
        }

        [HttpPost]
        public IEnumerable<AppointmentData> CreateRecurrenceException(WebApiData data)
        {
            return Controller.CreateRecurrenceException(data.SchedulerInfo, data.RecurrenceExceptionData);
        }

        [HttpDelete]
        public IEnumerable<AppointmentData> RemoveRecurrenceExceptions(WebApiData data)
        {
            return Controller.RemoveRecurrenceExceptions(data.SchedulerInfo, data.MasterAppointmentData);
        }

        [HttpDelete]
        public IEnumerable<AppointmentData> DeleteAppointment(WebApiData data)
        {
            return Controller.DeleteAppointment(data.SchedulerInfo, data.AppointmentData, data.DeleteSeries);
        }

        [HttpGet]
        public IEnumerable<ResourceData> GetResources(string schedulerInfo)
        {
            var o = new JavaScriptSerializer().Deserialize<MySchedulerInfo>(schedulerInfo);
            return Controller.GetResources(null);
        }

    }

    public class MySchedulerInfo { };




 




1 Answer, 1 is accepted

Sort by
0
Boyan Dimitrov
Telerik team
answered on 04 Apr 2014, 08:38 AM
Hello,

Please find attached a sample project that implements RadScheduler WebAPI scenario with CRUD operations with a database. Indeed the Web API allows to use your controller instead going through a web service in order to retrieve, insert, update and delete appointments. Please simply add the Telerik dll files in the Bin folder.


Regards,
Boyan Dimitrov
Telerik
 

Check out the Telerik Platform - the only platform that combines a rich set of UI tools with powerful cloud services to develop web, hybrid and native mobile apps.

 
Tags
Scheduler
Asked by
administrator
Top achievements
Rank 1
Answers by
Boyan Dimitrov
Telerik team
Share this question
or