Hierarchical layout for resources without grouping

Hi Syncfusion team

Is it possible to achieve hierarchical layout for resources in e.g. Timeline week view without grouping?
pseudo example...

Resources

25.26.27.... defaut......

Organization A


Event



  • Clinic A



Event

    • Department A

Event



      • Room A




Event

Clinic B


Event



  • Room B


Event


Organization C


Event

  • Site


Event


  • Room




Event
    • Device
Event




...






All Resources can but don't have to be in a parent child relationship. Any way to achieve this out of the box?
I have an idea on how to do it but its not out of the box... my approach would be to ...

  • sort the resources accordingly respecting the hierarchy but in a flat model
  • calculate and store indentation size to each resource item and attach them to schedule
  • if possible create a cell template for resource? to achieve indentation... is it possible?
  • the only thing left would be collapsing it but that might be not that much necessary
I plan to try it that way, any better ideas?

3 Replies 1 reply marked as answer

VD Vinitha Devi Murugan Syncfusion Team August 30, 2021 12:38 PM UTC

Hi Jason, 
 
Greetings from Syncfusion Support. 
 
We have validated your reported query “Is it possible to achieve hierarchical layout for resources in e.g. Timeline week view without grouping?” at our end and we have achieved your shared layout with the help of resourceHeaderTemplate property of our scheduler with below CSS for the same we have prepared below sample for your reference.  
 
 
<template> 
    <div> 
      <div class="col-md-12 control-section"> 
        <div class="content-wrapper"> 
          <ejs-schedule 
            id="Schedule" 
            height="700px" 
            :selectedDate="selectedDate" 
            :readonly="readonly" 
            :currentView="currentView" 
            :eventSettings="eventSettings" 
            :group="group" 
            :resourceHeaderTemplate="resourceTemplate" 
          > 
            <e-views> 
              <e-view option="TimelineWeek"></e-view> 
            </e-views> 
            <e-resources> 
              <e-resource 
                field="ProjectId" 
                title="Choose Project" 
                name="Projects" 
                :dataSource="projectResourceDataSource" 
                textField="text" 
                idField="id" 
                colorField="color" 
              > 
              </e-resource> 
            </e-resources> 
          </ejs-schedule> 
        </div> 
      </div> 
    </div> 
  </template> 
   
  <script> 
  import Vue from "vue"; 
  import { 
    SchedulePlugin, 
    Agenda, 
    TimelineViews, 
    TimelineMonth, 
    Resize, 
    DragAndDrop, 
  } from "@syncfusion/ej2-vue-schedule"; 
  import "@syncfusion/ej2-base/styles/material.css"; 
  import "@syncfusion/ej2-buttons/styles/material.css"; 
  import "@syncfusion/ej2-calendars/styles/material.css"; 
  import "@syncfusion/ej2-dropdowns/styles/material.css"; 
  import "@syncfusion/ej2-inputs/styles/material.css"; 
  import "@syncfusion/ej2-navigations/styles/material.css"; 
  import "@syncfusion/ej2-popups/styles/material.css"; 
  import "@syncfusion/ej2-vue-schedule/styles/material.css"; 
  Vue.use(SchedulePlugin); 
   
  var resourceTemplateVue = Vue.component("resource-template", { 
    template: 
      '<div class="template-wrap">' + 
      '<div class="Resource-details"><div :class="getClass" >{{getAirlineName(data)}}</div>' + 
      "</div></div>", 
    data() { 
      return { 
        data: {}, 
      }; 
    }, 
    computed: { 
      getClass: function () { 
        return this.getClassNameByLevel(this.data); 
      }, 
    }, 
    methods: { 
      getAirlineName: function (data) { 
        let value = JSON.parse(JSON.stringify(data)); 
        return value.resourceData 
          ? value.resourceData[value.resource.textField] 
          : value.resourceName; 
      }, 
      getClassNameByLevel: function (data) { 
        let value = JSON.parse(JSON.stringify(data)); 
        let className = value.resourceData.level; 
        return className === "one" 
          ? "levelOne" 
          : className === "two" 
          ? "levelTwo" 
          : className === "three" 
          ? "levelThree" 
          : "levelFour"; 
      }, 
    }, 
  }); 
  export default Vue.extend({ 
    data: function () { 
      return { 
        eventSettings: { 
          dataSource: [], 
          fields: { 
            subject: { 
              default: "Add Summary"// Set default value to subject 
            }, 
          }, 
        }, 
        readonly: false, 
        projectResourceDataSource: [ 
          { text: "Organization A"id: 1color: "#cb6bb2"level: "one" }, 
          { text: "Clinic A"id: 2color: "#cb6bb2"level: "two" }, 
          { text: "Department A"id: 3color: "#cb6bb2"level: "three" }, 
          { text: "Room A"id: 4color: "#56ca85"level: "four" }, 
          { text: "Clinic B"id: 5color: "#df5286"level: "one" }, 
          { text: "Room B"id: 6color: "#df5286"level: "two" }, 
          { text: "Organization C"id: 7color: "#df5286"level: "one" }, 
          { text: "Site"id: 8color: "#df5286"level: "two" }, 
          { text: "Room"id: 9color: "#df5286"level: "two" }, 
          { text: "Device"id: 10color: "#df5286"level: "three" }, 
        ], 
        resourceTemplate: function () { 
          return { template: resourceTemplateVue }; 
        }, 
        group: { 
          byGroupId: false, 
          resources: ["Projects"], 
        }, 
        selectedDate: new Date(201834), 
        currentView: "TimelineWeek", 
      }; 
    }, 
    provide: { 
      schedule: [AgendaTimelineViewsTimelineMonthResizeDragAndDrop], 
    }, 
    methods: {}, 
  }); 
  </script> 
  <style> 
  .levelOne { 
    margin-left0px; 
  } 
  .levelTwo { 
    margin-left15px; 
  } 
  .levelThree { 
    margin-left30px; 
  } 
  .levelFour { 
    margin-left45px; 
  } 
  </style> 
 
Output: 
 
 
Kindly try with the above sample and get back to us if you need any further assistance. 
 
Regards, 
Vinitha 


Marked as answer

DB Dino Balic September 1, 2021 06:24 AM UTC

Hi Vinitha Devi Murugan ,
thank you for the reply and the example, I've done it pretty much in the same way as you... so everything works as imagined

... but I was unable to achieve a "null resource" ... something like a global scale event whose resourceId is null.

I tried creating a resource like { id: null, name: "GLOBAL EVENT", etc ...} but after adding an event it gets ignored and its not shown under GLOBAL EVENTS

One option is to just add a resource for that purpose (with an id) and be done with it but I wonder if its achievable to show events that has `resourceId` (field mapping resources with events) value set to null?



NR Nevitha Ravi Syncfusion Team September 1, 2021 11:28 AM UTC

Hi Dino, 

Thanks for your update. /We are glad that our solution worked at your end.  

It is mandatory to set resource id, setting null to resource id does not map the events properly which is our current behavior. So we request you to set resource id for global events too at your end. 

Please let us know if you need any further assistance. 

Regards, 
Nevitha 


Loader.
Up arrow icon