Auto-fill additional values from select2 on row create

Auto-fill additional values from select2 on row create

bacalovbacalov Posts: 22Questions: 3Answers: 0

Hi,
I'm getting detailed information about a product through select2 ajax call (like product package, minPrice, maxQty)
Is there any way fill some of these values directly when creating new record, beside ID - this way I won't be forced to make another DB call to get these values again.

Thank's a lot.

Answers

  • allanallan Posts: 63,516Questions: 1Answers: 10,472 Site admin

    So basically you are looking to copy the information from one table to another rather than using a left join - is that correct?

    One option might be to use dependent() (or just a regular change event on the Select2 element) - when the value changes you could use the field().val() method to update the values of the other fields based on the item selected?

    Allan

  • bacalovbacalov Posts: 22Questions: 3Answers: 0
    edited July 2017

    Thank's Allan for the suggestions/direction,

    Finally figured out...
    Basically, I'm autofilling the Create fields with Select2 response values, like this:
    editor.set({
    field1: e.params.args.data.selectField1,
    field2: e.params.args.data.selectField2
    });

    Thank's again.

This discussion has been closed.