Open select control's list

Open select control's list

Karl53Karl53 Posts: 72Questions: 29Answers: 0

This is a follow-up to this select control question

I understand why the select control's list does not stay open. In the table's click event handler, there are business rules that must pass before Editor goes into inline mode.

This is my simplified code:

    $('#TVM').on('click', 'tbody td:not(:first-child)', function (e) {
        if (editor.display()) {
            editor.blur(); // !important, assure editor is closed and submitted
        }
        var d = table.row(selectedRow).data(); // get current row data
        /// test conditions, and
        if (rulesPass) {
            editor.inline(this);  // go into edit mode  --- but select list is not open
        }
    });

Is there a way, if the editor is a select control, to go into edit mode and have the select list open?

Thanks.

This question has an accepted answers - jump to answer

Answers

  • allanallan Posts: 61,853Questions: 1Answers: 10,134 Site admin
    Answer ✓

    You can certainly go into edit mode (as you have done), but as far as I am aware there is no API in the DOM to allow a select element to be opened programmatically. There are a number of StackOverflow threads on that topic (since it isn't specific to Editor) but they appear to confirm this.

    The only option would be to use something like Select2 or Selectize which will have an API to display the list as open automatically.

    Allan

  • Karl53Karl53 Posts: 72Questions: 29Answers: 0

    Thanks Allan. Thought you might have known some black magic. :smile:

    As it turns out, I was able to work around this and continue to use the native select by fine tuning the logic so as to avoid using a sledge hammer and calling editor.blur() with every click() event.

This discussion has been closed.