Get column type in ".refglobaloptions.OptionType;

Get column type in ".refglobaloptions.OptionType;

AnthonyVAnthonyV Posts: 37Questions: 7Answers: 0
edited July 2020 in Free community support

I would like to get the column type of a field in the preOpen event so that I can cancel editing on certain columns.

I am using Keys but I don't want to limit the user's ability to move around in the table.

The following code works but I suspect I am not using the correct API.

editor.on('preOpen', function (e, mode, action) {
  var column = editor.field($editor.modifier().column);
  // This works but I suspect I am not using the proper API.
  var columnType = column.s.opts.type;
  if (columnType == 'readonly')
    return false;
});

This question has an accepted answers - jump to answer

Answers

  • AnthonyVAnthonyV Posts: 37Questions: 7Answers: 0

    FYI: The title on this question is messed up. It should be "Get column type in 'preOpen' "

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

    Yep, you are going into the field object, which may change (but unlikely too). Another approach would be to check on the readonly attribute of the node, see here

    Colin

  • AnthonyVAnthonyV Posts: 37Questions: 7Answers: 0

    Okay, so...

    get the column with var column = editor.field($editor.modifier().column);

    and get the readOnly attribute

    using $(column.input()).attr('readonly')
    instead of column.s.opts.type

    Thanks.

This discussion has been closed.