search envelope-o feed check
Home Unanswered Active Tags New Question
user comment-o

custom resource field

Asked by Gaona Jandri
2 years ago.

Hello!
I am using the vue.js component and would like to use a custom resource field called 'role' as the default name when creating the event.
how can I do?

Answer posted by Dan Letecky [DayPilot]
2 years ago.

You'll need to transform your data set to match the data structure required by the Scheduler. It displays the name specified by the "name" property:

https://api.daypilot.org/daypilot-scheduler-resources/

Example:

const yourResources = [ /* ... */ ];
const resources = yourResources.map(r => {
  return {
    ...r,
    name: r.role
  };
});

When you display custom row header columns (https://doc.daypilot.org/scheduler/row-header-columns/) you can specify a which property of the data source item will be used as content:

config: {
  // ...
  rowHeaderColumns: [
    { name: "Role", display: "role"}
  ]
}
Comment posted by Gaona Jandri
2 years ago.

Thanks for the help but that's not what I'm looking for.
I need the custom field called 'role' to be used as the name of the event when it is created.
my resources are structured as follows:
[{
id: 1,
name: "John",
role: "waiter"
}, .... ]
inside the 'args' argument of OnTimeRangeSelected the 'role' field is not present.
Is there any way to access that field?

Comment posted by Dan Letecky [DayPilot]
2 years ago.

Oh, sorry.

In onTimeRangeSelected, you can access the source data object this way:

onTimeRangeSelected: args => {
  const row = dp.rows.find(args.resource);   // dp -> DayPilot.Scheduler object
  const role = row.data.role;
  // ...
}
This question is more than 1 months old and has been closed. Please create a new question if you have anything to add.