- Home
- Forum
- ASP.NET MVC
- Unable to add multiple resource in schedule, Giving JavaScript Error
Unable to add multiple resource in schedule, Giving JavaScript Error
I am using Schedule to show planned activities with multiple resource. As per the guideline / help provided, I used same code, but it is giving me JavaScript Error.
My .cshtml file:
@model LuxCRM.Models.PlannerModel
@{
ViewBag.Title = "Planner";
var v = Model.PlannerData; //this holds schedule data;
var v1 = Model.SalesEmployees; // this hold resources
}
<h2>@Html.LabelFor(model => model.PlannerHeading)</h2>
@using (Html.BeginForm())
{
<div>
@(Html.EJ().Schedule("Schedule1")
.Width("100%")
.Height("500px")
.AllowDragDrop(false)
.Resources( res =>
{ res
.Field("SlpCode").Title("SlpCode").Name("SlpCode").AllowMultiple(false)
.ResourceSettings(flds=> flds
.Datasource(v1)
.Text("EmployeeName")
.Id("SlpCode")
.Color("Color")
).Add();
}
)
.Group(gr => { gr.Resources(Model.Resource); })
.AllowKeyboardNavigation(true)
.HighlightBusinessHours(true)
.IsResponsive(true)
.ShowTimeScale(true)
.ShowCurrentTimeIndicator(false)
.CurrentView(Syncfusion.JavaScript.CurrentView.Week)
.TimeMode(Syncfusion.JavaScript.TimeMode.Hour12)
.AppointmentSettings(fields => fields.Datasource(v)
.Id("ClgCode")
.Subject("Subject")
.StartTime("StartDate")
.EndTime("EndDate")
.Description("Subject")
)
)
</div>
}
My Model :
public class PlannerModel
{
public PlannerModel()
{
PlannerData = new List<PlannerData>();
PlannerHeading = "Scheduler / Planner";
}
public List<Models.PlannerData> PlannerData { get; set; }
[Display(Name = "PlannerHeading", ResourceType = typeof(Resource))]
public string PlannerHeading { get; set; }
public List<SalesEmployee> SalesEmployees { get; set; }
public List<String> Resource { get; set; }
}
I don't see any problem in this code, I don't understand why it gives me JavaScript error.
I also wanted to understand DataSource (here)method, how it works and what type of data it expect specially first 2 property.
I also observed that it is not picking up the timing correctly. Please see the below screen shot of my data coming from HANA.
Timing is pulled correctly from database and it is set in List<> correctly. But while rendering schedule control it shows wrong timing.
Hi Manish,
Thanks for contacting Syncfusion support.
Please find the following responses for your queries.
Query1: Script error throws while rendering the multiple resource
When the resources are used in the scheduler, it is mandatory to map the resource field with the AppointmentSettings. Refer to the following code example to map the ResourceField,
<Code>
AppointmentSettings(fields => fields.Datasource(ds => ds.URL("/Home/GetData").CrudURL("/Home/Batch").Adaptor("UrlAdaptor"))
.Id("Id")
.Subject("Subject")
.StartTime("StartTime")
.StartTimeZone("StartTimeZone")
.EndTimeZone("EndTimeZone")
.EndTime("EndTime")
.Description("Description")
.AllDay("AllDay")
.Recurrence("Recurrence")
.RecurrenceRule("RecurrenceRule")
.ResourceFields("OwnerId"))
</Code>
Query2: Need to understand about Datasource methods
For example: AppointmentSettings(fields => fields.Datasource(ds => ds.URL("/Home/GetData").CrudURL("/Home/Batch").Adaptor("UrlAdaptor")))
For example: ResourceSettings(flds => flds.Datasource(ViewBag.Owners).Text("text").Id("id").GroupId("groupId").Color("color")).Add();
Note: To know more about datasource and datamanager, visit the below User Guide links,
Datasource:
http://help.syncfusion.com/js/schedule/data-binding
Datamanager:
http://help.syncfusion.com/js/datamanager/overview
Query3: Appointments are not rendering in given time
We request you to include the StartTimeZone and EndTimeZone fields in the datasource in order to render the appointments at the same time as given in the datasource. We have prepared the sample for the queries 1 and 3, which can be downloaded from the following location,
http://www.syncfusion.com/downloads/support/forum/121159/ze/ScheduleCRUD-1551034082
In the above sample, we have included the ResourceFields, StartTimeZone, and EndTimeZone within the AppointmentSettings. TheStartTimeZone and EndTimeZone fields are included in the datasource. So, the appointments will be rendered at the same time as given in the datasource.
Regards,
Karthigeyan
Thanks for your support. My problem is resolved and the sample you provided helps me to understand schedule control better.
Once again thanks a lot.
Thanks for your update.
We are happy to hear that our solution has resolved your issue.
Regards,
Karthigeyan
- 4 Replies
- 2 Participants
-
MA Manish
- Nov 16, 2015 06:26 AM UTC
- Nov 19, 2015 03:57 AM UTC