Our powerful JS Calendar component


Post by lxxrxns »

Hi! I'm trying to set the calendar (i.e. resource) of an event dynamically depending on the name that is selected:

Image

However, while the calendar field visually does change, it's value when submitting the event does not (the default calendar/resource value is submitted):

Image

While changing the calendar manually works correctly:

Image

Please find my code below.
I'm using the change listener to set the value of the resourceField, but as shown above, this seems to only affect the field's value, and not the actual calendar that the event is allocated to.

Can someone please explain how to change the calendar (resource) of an event dynamically?
Thanks a lot!

features : {
    eventEdit : {
      items : {
        nameField : {
          type   : 'combo',
          name   : 'name',
          ref    : 'titelSelect',
          label  : 'Titel',
          valueField   : 'name', 
          displayField : 'name', 
          listItemTpl : item => StringHelper.xss`<div class="color-box b-sch-${item.eventColor}"></div><div>${item.name}</div>`,
          items : [
            ...
          ],
          listeners   : {
            change : ({ source : combo, value, eventRecord }) => {
              const resourceField = combo.owner.widgetMap.resourceField;
              resourceField.value = value;
            }
          }
        },
        assistentId : {
          weight : 101,
          type   : 'combo',
          name   : 'assistentId',
          label  : 'Assistent',
          valueField   : 'id', 
          displayField : 'name', 
          items  : [
           ...
          ]
        },
        resourceField : {
          hidden : false,
          ref : 'resourceField'
        }
      }
    },
    eventTooltip : {
      align : 'l-r'
    }
  }

Post by alex.l »

Your code in not runnable, so I tried this in our online example https://bryntum.com/examples/calendar/basic/

    features : {
        eventEdit : {
            items : {
                nameField : {
                    listeners   : {
                        input : ({ source , value, eventRecord }) => {
                            const resourceField = source.owner.widgetMap.resourceField;
                            resourceField.value = 'bryntum';
                        }
                    }
                }
            }
        },

All works to me. Please check video attached.
Try to reproduce it with our examples and check if you are using the latest version of the Calendar (5.0.3).

Attachments
Screen Recording 2022-05-02 at 18.19.05.mov
(4.06 MiB) Downloaded 50 times

All the best,
Alex


Post Reply