Select options as a callback?

Select options as a callback?

rocketreadingrocketreading Posts: 8Questions: 6Answers: 0

Hi there,

I'm looking to find a way to have a cell's select options dependant on another field's value - and when that other field's value changes, the field's options change (just for that row).

Is this possible?

Many thanks.

This question has an accepted answers - jump to answer

Answers

  • allanallan Posts: 63,498Questions: 1Answers: 10,471 Site admin

    Hi,

    The dependent() method was designed to handle this. This example shows how dependent() can be used, albeit not to update an options list in this case, but that is an option based on the returned information.

    Allan

  • rocketreadingrocketreading Posts: 8Questions: 6Answers: 0
    edited October 2015

    Thank you.

    Two things: how do I access the correct row/cell to update with the below? Also - how can I ensure the host field is updated server-side?

    Many thanks.

      editors[id].dependent('company_id', function(val, data, callback) {
    
                    // get tests code
    
                        var tests = new Object;
    
                        for (var test in $response.company.tests) {
                            // add as option to Test field
                            tests[$response.company.tests[test].id] = $response.company.tests[test].name;
                        }
    
                        editor.field('test_id').update(tests);
    
                    });
    
                });
    
  • allanallan Posts: 63,498Questions: 1Answers: 10,471 Site admin
    Answer ✓

    how do I access the correct row/cell to update with the below?

    The row information is passed in using the data property - that will give the information about the row that is currently being edited, and thus (I presume) what you want to base the options upon?

    Also - how can I ensure the host field is updated server-side?

    The value should be submitted as normal when you submit the form.

    Allan

This discussion has been closed.