Page 1 of 1

[VUE] Select value from combofield to complete other field on taskEditor

Posted: Thu Oct 19, 2023 8:12 pm
by tobias.aires

Hello, i'm using scheduler pro component and i want to know if is it possible to put value on "Repórter" and "Editor Texto" field automatically when i select one value from combofield "Retranca"?

I can get the value, but i can't put the value on the respective field.

    this.schedulerpro.eventStore.on('change', (e) => {
      if (
        e.action === 'update' &&
        Object.keys(e.changes).includes('retranca')
      ) {
        const selectedRetranca = e.changes['retranca'].value;

    const [{ reporter }] = retrancas.filter((retranca) => {
      if (retranca.name === selectedRetranca) {
        return retranca;
      }
    });
  }

Re: [VUE] Select value from combofield to complete other field on taskEditor

Posted: Thu Oct 19, 2023 9:15 pm
by marcio

Hey tobias,

That will depend on how you set up the event editor, so if you could provide a sample of how are your Scheduler configured, it would help a lot.

Besides that, you can check the widget map and try to find the inputs that you need to change, and from there just set the value directly in the TextField. https://bryntum.com/products/schedulerpro/docs/api/Core/widget/Container#property-widgetMap

https://bryntum.com/products/schedulerpro/docs/api/Core/widget/TextField#property-value

schedulerPro.widgetMap

Re: [VUE] Select value from combofield to complete other field on taskEditor

Posted: Thu Oct 19, 2023 10:04 pm
by tobias.aires

Here a draft of my taskEdit config.

   taskEdit: {
      editorConfig: {
        bbar: {
          // Remove delete button
          items: {
            deleteButton: false,
          },
        },
        autoClose: false,
        height: 550,
        width: 520,
      },
      items: {
        notesTab: false,
        predecessorsTab: true,
        successorsTab: true,
        advancedTab: {
          // Calendar: 'CALL',
          items: {
            calendarField: false,
            manuallyScheduledField: false,
            ignoreResourceCalendarField: false,
            // inactive: null
          },
        },
        generalTab: {
          items: {
            resourcesField: false,
            percentDoneField: false,
            effortField: false,
            durationField: false,
            endDateField: false,
            nameField: false,

        retranca: {
          required: true,
          type: 'combo',
          label: 'Retranca *',
          name: 'retranca',
          items: [{name: 'retranca 1', reporter: 'Anderson'}].map(retranca => retranca.name),
        },
        textEditor: {
          type: 'textfield',
          label: 'Editor texto',
          name: 'textEditor',
        },
        reporter: {
          type: 'textfield',
          label: 'Repórter',
          name: 'reporter',
        },
        videoEditor: {
          required: true,
          type: 'combo',
          label: 'Editor mídia *',
          name: 'videoEditor',
        },
        ilha: {
          required: true,
          type: 'combo',
          label: 'Ilha/Ramal *',
          name: 'ilha',
        },
        startDateField: {
          required: true,
          type: 'date',
          label: 'Exibição *',
        },
      },
    },
  },
},

"
When i do

console.log(this.schedulerpro.widgetMap)

i get this object, but i could not find the getWidgetById method, in any of the objects returned


Re: [VUE] Select value from combofield to complete other field on taskEditor

Posted: Thu Oct 19, 2023 11:41 pm
by marcio

Hey,

Thanks for sharing the configuration, you can change the value of the inputs with the following snippet (for the text editor)

schedulerPro.features.taskEdit.editor.widgetMap.textEditor.value = "new editor"

schedulerPro.features.taskEdit.editor.widgetMap will contain all the inputs that you need to set the value.

You can add your feature configuration here https://bryntum.com/products/schedulerpro/examples/non-working-time/ and test it


Re: [VUE] Select value from combofield to complete other field on taskEditor

Posted: Fri Oct 20, 2023 6:54 am
by Animal

Where possible, new Widgets are created only when needed for perf reasons.

So the editor gets created when you first need it. This principle goes all the way down. The dropdown of a combobox is only created when you first show it.

The code above references the "editor" property of the feature and forces it into existence.

From what I understand, it seems like you need a change listener:

        retranca: {
          required: true,
          type: 'combo',
          label: 'Retranca *',
          name: 'retranca',
          // This is a strange way of doing things v
          items: [{name: 'retranca 1', reporter: 'Anderson'}].map(retranca => retranca.name),
          listeners : {
            // Will look in the ownership hierarchy
            change : 'up.onRetrancaChange'
          }
        }

Configure onRetrancaChange into your Scheduler instance. That method will have access to all widgets and can do all the dynamic changes you need.


Re: [VUE] Select value from combofield to complete other field on taskEditor

Posted: Fri Oct 20, 2023 8:55 pm
by tobias.aires

I tried to use listeners property, but o i get this object that represents the event. I'm still not knowing what i have to do to set the other field some value.


Re: [VUE] Select value from combofield to complete other field on taskEditor

Posted: Sat Oct 21, 2023 12:20 am
by marcio

Hey tobias,

If you set it up as Animal mentioned, you can use the following snippet, and this will be the SchedulerPro instance, and from there, you can follow the approach that we suggested.

onRetrancaChange: function(ev) {
	const schedulerPro = this;
	schedulerPro.features.taskEdit.editor.widgetMap.textEditor.value = "new editor";
}

or you can use the following snippet too

onRetrancaChange: function({ source }) {
	const { parent } = source;
	parent.widgetMap.textEditor.value = "new editor";
}