How to dynamically disable one field from inline edits?

How to dynamically disable one field from inline edits?

hadohado Posts: 2Questions: 1Answers: 0

I have a DataTable with Editor and KeyTable and there is a requirement to enable/disable editing of a field based on another field. Is this possible? I saw this example but it's disabling the entire row, not a specific field.

I'm already using a class to define which column is editable. Should I control cell edit-ability by setting the cell class dynamically based on row content (not sure how) or some other way?

This question has an accepted answers - jump to answer

Answers

  • Tester2017Tester2017 Posts: 145Questions: 23Answers: 17
    edited March 2018 Answer ✓

    The next example is disabling inline editing for a field called 'user.first_name'. But you can add your own logic to return false. For example, testing if field hasClass.

    editor.on('preOpen', function(e, mode, action) {
        var fieldName = e.currentTarget.s.includeFields[0];
        // console.log(fieldName);
            if (fieldName === `users.first_name`) {
        return false;
    }
    
  • hadohado Posts: 2Questions: 1Answers: 0

    Thank you, this helped solve our problem precisely!

This discussion has been closed.