Search results

Prioritize the Resource Color for Events

08 Apr 2021 / 1 minute to read

By default top level resource color will be applied for the events. If user wants to apply specific resource color to events irrespective of its parent resource color, it can be achieved by resourceColorField field within eventSettings property as shown below.

tagHelper
data.cs
Copied to clipboard
@using Syncfusion.EJ2

@section ControlsSection{
    <div class="control-section">
        <div class="control_wrapper schedule-control-section">
            <ejs-schedule id="schedule" height="550" views="@ViewBag.view" currentView="WorkWeek" selectedDate="new DateTime(2018, 2, 15)" navigating="onNavigating">
                <e-schedule-group byGroupID="false" resources="@ViewBag.Resources"></e-schedule-group>
                <e-schedule-resources>
                    <e-resource dataSource="@ViewBag.Projects" field="ProjectId" title=" Choose Project" name="Projects" textField="text" idField="id" colorField="color"></e-resource>
                    <e-resource dataSource="@ViewBag.Categories" field="CategoryId" title="Category" name="Categories" textField="text" idField="id" colorField="color" allowMultiple="true"></e-resource>
                </e-schedule-resources>
                <e-schedule-eventsettings dataSource="@ViewBag.datasource"></e-schedule-eventsettings>
            </ejs-schedule>
        </div>
    </div>
}
Copied to clipboard
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using Microsoft.AspNetCore.Mvc;
using WebApplication1.Models;

namespace WebApplication1.Controllers
{
    public partial class ScheduleController : Controller
    {
        public ActionResult resource-color()
        {
            ViewBag.datasource = new ScheduleData().GetResourceTeamData();

            List<ProjectResource> projects = new List<ProjectResource>();
            projects.Add(new ProjectResource { text = "PROJECT 1", id = 1, color = "#cb6bb2" });
            projects.Add(new ProjectResource { text = "PROJECT 2", id = 2, color = "#56ca85" });
            ViewBag.Projects = projects;

            List<CategoryResource> categories = new List<CategoryResource>();
            categories.Add(new CategoryResource { text = "Development", id = 1, color = "#1aaa55" });
            categories.Add(new CategoryResource { text = "Testing", id = 2, color = "#7fa900" });
            ViewBag.Categories = categories;

            ViewBag.Resources = new string[] { "Projects", "Categories" };
            return View();
        }
    }
    public class ProjectResource
    {
        public string text { set; get; }
        public int id { set; get; }
        public string color { set; get; }
    }
    public class CategoryResource
    {
        public string text { set; get; }
        public int id { set; get; }
        public string color { set; get; }
    }
}

The resourceColorField field value should be as same as the name field value given with in resources property.