Discuss anything related to web development but no technical support questions


Post 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;
      }
    });
  }
Attachments
photo_2023-10-19_14-54-51.jpg
photo_2023-10-19_14-54-51.jpg (44.86 KiB) Viewed 958 times

Post 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

Best regards,
Márcio


Post 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

Attachments
photo_2023-10-19_17-00-56.jpg
photo_2023-10-19_17-00-56.jpg (70.84 KiB) Viewed 943 times

Post 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

Best regards,
Márcio


Post 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.


Post 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.

Attachments
photo_2023-10-20_15-55-10.jpg
photo_2023-10-20_15-55-10.jpg (21.5 KiB) Viewed 890 times

Post 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";
}

Best regards,
Márcio


Post Reply