[Editor] Adjusting options before row data is set

[Editor] Adjusting options before row data is set

HPBHPB Posts: 73Questions: 2Answers: 18
edited October 2016 in Free community support

Is it possible to adjust options before row data is set when edit window ('main') is opened?

What I would like to do is dynamicly build the options before row data is set, so when it is set it will select the correct option.
The first event (initEdit) is already after row data is set.

Simplified use case:
I have a field 'status', which can be 1-10. My status can only go forward, or backwards by 1, so when I edit a row with status=5 I want my options to be 4-10.
When I close the edit window and try to edit a row with status 3, options must be 2-10.
What happens now is that it tries to find value 3 in the old list (4-10) and can't find it, so it won't select it.

I hope that is clear enough.

Replies

  • HPBHPB Posts: 73Questions: 2Answers: 18
    edited October 2016

    Is calling editor.field('status').update(options); right before calling editor.edit(row); the way to go here?

    My actual use case has multi level dependencies, and this way I need to have the logic in two places. In the onclick right before editor.edit() and in dependent()

    Is there a specific reason why set is called before dependent() in form creation?

  • allanallan Posts: 63,818Questions: 1Answers: 10,517 Site admin

    Yes, using the field's update() method just after calling edit() sounds like a good option to me here.

    The dependent() method might not be too useful in this case, as the field is dependent on its own value!

    Is there a specific reason why set is called before dependent() in form creation?

    It has to be - dependent() is triggered by a value change on the field, which happens when the field's value is set.

    Allan

This discussion has been closed.