Our pure JavaScript Scheduler component


Post by hammadch360 »

Hi. This is Hammad. I have a query. I need a specific events list that is assigned to each resource. I am using Bryntum Scheduler Pro. From which key, I can get a list of events that are assigned to each resource.

columns: [
            { type: 'tree', text: 'Name', field: 'name', width: 180, tree: true, showRole: true },
            { text: 'Designation', field: 'designation', width: 90 },
            { text: 'Actions', type: 'action', width: 50, align: 'center',
                actions: [{
                    cls: 'b-fa b-fa-fw b-fa-plus',
                    tooltip: ({ record }: any) =>
                        record.originalData.type == 'c' ? 'Add Project' : 'Add Resource',
                    renderer: ({ record }: any) =>
                        record.originalData.type != 'r' ? (record.originalData.type == 'c' ?
                        '<i style="cursor: pointer;" class="b-action-item b-fa b-fa-plus"></i>' :
                        '<i style="cursor: pointer;" class="b-action-item b-fa b-fa-plus"></i>') : '',
                    onClick: ({record, eventRecord}: any) => {
                        this.onSelectChange(record, eventRecord);
                    }
                }]
            }
        ],

On this onSelectChange the object, I receive where I did not find any list of events.


Post by alex.l »

All the best,
Alex


Post by hammadch360 »

Thank you for your response.


Post by hammadch360 »

Hi. I need resource property on saving the event. I am using onBeforeEventSave($event) function to get the property but in this i did not found resource property. I am getting this object showing in Code. Can you tell how can i get that property.

editor: K {configureAriaDescription: undefined, _isAnimatingCounter: 0, alignConstrained: 0, byRef: {…}, callRealign: ƒ, …}
eventRecord: t {originalData: {…}, meta: {…}, _internalId: 1106, stores: Array(1), unjoinedStores: Array(0), …}
eventRecords: [t]
source: D {configureAriaDescription: undefined, _isAnimatingCounter: 0, alignConstrained: 0, isInTimeAxis: ƒ, onDeleteKey: ƒ, …}
taskRecord: t {originalData: {…}, meta: {…}, _internalId: 1106, stores: Array(1), unjoinedStores: Array(0), …}
type: "aftereventsave"
[[Prototype]]: Object

Thanks. Please reply me ASAP


Post by mats »

Please share your code of the onBeforeEventSave so we can see where you access the resource


Post by hammadch360 »

 <bryntum-scheduler-pro #scheduler [startDate]="schedulerProConfig.startDate" [endDate]="schedulerProConfig.endDate" [viewPreset]="schedulerProConfig.viewPreset" [eventStyle]="eventStyle" [tickSize]="schedulerProConfig.tickSize" [columns]="schedulerProConfig2.columns"
        [resourceImagePath]="schedulerProConfig.resourceImagePath" [project]="schedulerProConfig.project" [infiniteScroll]="schedulerProConfig.features.infiniteScroll" [visibleDate]="schedulerProConfig.visibleDate" [rowHeight]="schedulerProConfig.rowHeight"
        [treeFeature]="true" [regionResizeFeature]="schedulerProConfig.features.regionResize" [percentBarFeature]="schedulerProConfig.features.percentBar" [resourceNonWorkingTimeFeature]="schedulerProConfig.features.resourceNonWorkingTime" [cellEditFeature]="schedulerProConfig.features.cellEdit"
        [filterFeature]="schedulerProConfig.features.filter" [dependenciesFeature]="schedulerProConfig.features.dependencies" [dependencyEditFeature]="schedulerProConfig.features.dependencyEdit" [eventTooltipFeature]="schedulerProConfig.features.eventTooltip"
        (onResourceHeaderClick)="onResourceContextMenu()" [listeners]="schedulerProConfig2.listeners" [columnLines]="schedulerProConfig.columnLines" [multiEventSelect]="true" [selectedRecord]="selectedRecord" (onCellClick)="onSelectionChange($event)" (onEventAutoCreated)="onEventAutoCreated($event)"
        (onAfterEventSave)="onAfterEventSave($event)" (onBeforeEventSave)="onBeforeEventSave($event)" (onBeforeEventAdd)="onBeforeEventAdd($event)" (onEventEditBeforeSetRecord)="onEventEditBeforeSetRecord($event)" ></bryntum-scheduler-pro>

and in .ts file

/** On Before Event Saved */
    onBeforeEventSave(e: any): void {
        console.log("Saved before!", e);
    }

Post by hammadch360 »

Is resource property missing or Can I get that from another way?


Post by alex.l »

Please check docs https://bryntum.com/docs/scheduler-pro/api/SchedulerPro/feature/TaskEdit#event-beforeEventSave
event in that context doesn't mean eventRecord, it means JavaScript event object.
That object has eventRecord property. eventRecord - is that you need.

All the best,
Alex


Post by hammadch360 »

Actually, I need resourceRecord property, Like you can say that each event is assigned to any resource, so I need that resource detail. So, How I can get the resource property.


Post by alex.l »

I described that here viewtopic.php?p=105458#p105458

Every resource has events property. Please see SchedulerPro.model.ResourceModel#property-events

Every event has a property with resources it assigned SchedulerPro.model.EventModel#field-resources

All resources are placed in resourceStore, all events - in eventStore
SchedulerPro.view.SchedulerPro#property-eventStore
SchedulerPro.view.SchedulerPro#property-resourceStore

So, what you need is:

    onBeforeEventSave({ eventRecord }) {
        const resourceRecords = eventRecord.resources; // array of resource records 
    }

All the best,
Alex


Post Reply