Dynamically change the Editor 'select' options as per another 'select' value

Dynamically change the Editor 'select' options as per another 'select' value

lzh8430lzh8430 Posts: 6Questions: 4Answers: 0

I'm using the Editor to edit table in which have 2 fields in the type of 'select', now I'd like to change one cell's options as per another cell's changed data, for example:
Cell-1 have options ['a', 'b'], change its value from 'a' to 'b', Cell-2 options are changed from ['a-1', 'a-2'] to ['b-1', 'b-2'].
How can i do that?
Thanks...

This question has an accepted answers - jump to answer

Answers

  • tangerinetangerine Posts: 3,348Questions: 36Answers: 394
    Answer ✓

    Cascading lists example:
    https://datatables.net/blog/2017-09-01

  • lzh8430lzh8430 Posts: 6Questions: 4Answers: 0

    Thank you tangerine.

    I add a line of code in JS after the editor created:
    editor.dependent('system', '/api/subsystem')

    and define a <post> interface to get the response:
    {
    "options": {
    "system" [
    { "label": XXX, "name": XXX},
    ......
    { "label": XXXX, "name": XXXX},
    ]
    }
    }

    But while I tried to edit the table, here comes a new problem, the <post> request are triggered constantly, and subsystem field kept blinking, I have to stop the backend server.
    What do I miss on the usage of API dependent()?
    Thanks.

  • lzh8430lzh8430 Posts: 6Questions: 4Answers: 0

    Sorry, I made a mistake, In my code I gave the wrong value for the first argument of editor.dependent('system', '/api/subsystem').
    Problem solved, thanks!

This discussion has been closed.