[Editor] - dependent API - Is triggered in every cell

[Editor] - dependent API - Is triggered in every cell

VascoSaavedraVascoSaavedra Posts: 42Questions: 8Answers: 1

According to the dependent API:

By default the dependent() method will trigger an update call whenever a change event is activated upon the field's input element

But, what i see is that this is triggered every time, without a changed in the dependent input field.

For example, assuming the following fields:

var editorFields = [
{
    label: "id",
    name: "id"
},
{
    label: "name",
    name: "name"
},
{
    label: "username",
    name: "username",
    type: "select"
}];

And the following dependent binding:

editor.dependent('id', function(val) {
     console.log("ID Changed");
});

I would assume that only when the ID field changes, it would be triggered.
But it seems it's triggered every time there is a focus in every cell.

Please see a live example here, and check the console log.

This question has an accepted answers - jump to answer

Answers

  • allanallan Posts: 63,306Questions: 1Answers: 10,433 Site admin

    This is actually correct and expected. What is happening when you click on a cell is that you are activating inline editing - only the target cell is shown to be editable by the end user, but actually the whole row is placed into editing mode (allowing other values in the row to be edited via the API if needed).

    Since the row needs to set the values, the dependent method is executed.

    Regards,
    Allan

  • VascoOliveiraVascoOliveira Posts: 22Questions: 7Answers: 0

    Thank you for your response.

    What would be the best approach to "filter" for changes in the specific field only?

  • allanallan Posts: 63,306Questions: 1Answers: 10,433 Site admin
    Answer ✓

    I was thinking about this last night - there is actually an option to place Editor into a mode whereby only the requested cell will be put into edit mode (not the rest of the row as well). This is controlled by the scope option of the form-options object.

    Note that if you are using KeyTable for the inline editing, you'd need to set the scope using the formOptions.inline object.

    Allan

This discussion has been closed.