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

How to wrap the text in Modal input box?

Asked by pushplata
1 year ago.

HI,

I have to wrap the text of the modal input box and have to customize the input height according to content.
plz guide me.

Thanks in advance

Answer posted by Dan Letecky [DayPilot]
1 year ago.

You can use the "textarea" form item:

import {Modal} from '@daypilot/modal';

// ...

const form = [
  {
    type: 'textarea',
    id: 'textarea1',
    name: 'Multi-line text',
  },
];
const data = {};

Modal.form(form, data).then(modal => {
  console.log(modal.result);
});
Comment posted by pushplata
1 year ago.

How to edit the event with text area?

Comment posted by Dan Letecky [DayPilot]
1 year ago.

The event data need to be passed as "data" parameter.

Let's say you have the following event:

{
  start: "2022-06-01T00:00:00",
  end: "2022-06-05T00:00:00",
  text: "Long description",
  resource: 1,
  id: 1
}

In onEventClick (and other events), you get DayPilot.Event object which stores the original object under "data" property (see also https://api.daypilot.org/daypilot-event-data/).

You can open the modal dialog like this:

onEventClick: async args => {
  const data = args.e.data;
  const form = [
    {
      type: 'textarea',
      id: 'text',
      name: 'Event description',
    },
  ];
  const modal = await DayPilot.Modal.form(form, data);
  console.log("updated data object", modal.result);
}

The form[].id property specifies the source of the item data (in this case it will read the description from data.text).

This question is more than 1 months old and has been closed. Please create a new question if you have anything to add.