Change row dropdown options based on inline change

Change row dropdown options based on inline change

stephanbstephanb Posts: 36Questions: 11Answers: 0

Imagine I'm doing inline editing of a row, and I just changed a dropdown selection.
Is it possible to Editor.field.update() the selection options of another Editor dropdown field in that row?

This question has an accepted answers - jump to answer

Answers

  • colincolin Posts: 15,237Questions: 1Answers: 2,599
    Answer ✓

    Yep, you can use dependent() to do that. This thread goes into some depth on that,

    Colin

  • stephanbstephanb Posts: 36Questions: 11Answers: 0
    edited March 2021

    lalalala, please ignore this reply. Still working on it :)

  • stephanbstephanb Posts: 36Questions: 11Answers: 0

    I'm almost there. One thing I noticed is when I make a change to the monitored field (field '2'), DataTables POSTs a change for the secondary field (field '3') as well, even though I haven't made a selection on it yet.

    Here are the relevant lines:

    editor.dependent('2', function (val, data, callback) {
        console.log(val);
        console.log(JSON.stringify(data));
        var retValue = {
            "options": {
                "3": [
                    { label: "", value: 0 },
                    { label: "On Hold", value: 1 },
                    { label: "Building/Securing", value: 2 },
                    { label: "Equivalent", value: 3 }
                ]
            }
        };
        return retValue;
    });
    

    From my server side logs:

    RECEIVED: 
     data[208][2]=1B
     data[208][3]=0
     action=edit
    

    I don't want to set a value to '3' yet, until I actually pick one and trigger a submit.

  • stephanbstephanb Posts: 36Questions: 11Answers: 0

    Besides the unintended change of value to field '3', I am also having trouble getting the dropdown to show the 'label' after a change is made to '3'. I see the value, but not the name associated with it. What could that be?

  • allanallan Posts: 63,226Questions: 1Answers: 10,416 Site admin

    If you are using dependent() with inline editing, you need to be using Editor 2's ability to show multiple fields inline at the same time. Is that what you are doing? dependent() with a single field at a time just doesn't work very well.

    Allan

  • stephanbstephanb Posts: 36Questions: 11Answers: 0

    I can't use Editor 2 yet until that datetime issue I sent you a message about is resolved. Can you have a look at that for me please? I'm also not sure what you mean with showing multiple inline fields at the same time.
    Once the datetime issue is fixed I'll be able to share a live setup to show what I'm doing.

  • allanallan Posts: 63,226Questions: 1Answers: 10,416 Site admin

    I'll look at your PM in just a moment!

    For what I mean with multiple inline fields at a time, see this new example.

    Allan

This discussion has been closed.