Our pure JavaScript Scheduler component


Post by Mattis »

Hi,
I want a field in my event editor to become visible if several of available values in another field is selected.
I get it to work if i only specify on value - as in the example here:
https://www.bryntum.com/examples/scheduler/eventeditor-combos/

But I want the field to be visible based on several values.

I have tried different variations, but cannot get it to work.


Post by Mattis »

 renovationYearField: {
                type: 'combo',
                name: 'renovationYear',
                label: 'Oppussing',
                weight: 120,
                items: ['Booking har ikke tid', 'Kunden vil ikke svare', 'Husker ikke', '1 år siden', '2 år siden', '3 år siden', '4 år siden', '5-10 år side', '10-15 år siden', '15-20 år siden', '20-25 år siden', '25-30år siden', '>30 år siden'],
                listeners: {
                  change: ({ source: combo, value }) => {
                    combo.owner.items.forEach(widget => {
                      if (widget.dataset && widget.dataset.renovationYear) {
                        widget.hidden = widget.dataset.renovationYear !== value;
                      }
                    });
                  }
                }
              },
              renovationWorkField: {
                type: 'combo',
                name: 'renovationWork',
                label: 'Utført',
                weight: 120,
                items: ['Booking har ikke tid', 'Kunden vil ikke svare', 'Husker ikke', 'Mindre elektrisk arbeid', 'Mellomstort elektrisk arbeid', 'Stort elektrisk arbeid', 'Sikringsskap'],
                dataset: { renovationYear: '1 år siden' }
              },

I want the renovationWorkField become visible if values "1 år siden", "2 år siden", "3 år siden" is selected in the renovationYearField


Post by pmiklashevich »

Hello,

You can find an example of Cascading combos concept in Grid examples (you can download trial to check locally): https://www.bryntum.com/examples/grid/cascadingcombos/

In the eventeditor-combos example the dataset approach is used, which is kind of limited. We have a ticket to show alternative approach: https://github.com/bryntum/support/issues/2009

Basically the idea is to subscribe to beforeEventEditShow event, get the editor fields, add listeners to control the behaviour. You can find an example here: viewtopic.php?p=83344#p83344

Best,
Pavel

Pavlo Miklashevych
Sr. Frontend Developer


Post Reply