how can get editor.filed(x).text?

how can get editor.filed(x).text?

moonoo1moonoo1 Posts: 11Questions: 6Answers: 0

hi.. I have a question.

  var editor = new $.fn.dataTable.Editor({
    ajax: "script.php", 
    table: "#example",
    fields: [
      {
        label: "product:",
        name: "code",
        type: "select",
        options: [
          { label: "product1", value: "A" },
          { label: "product2", value: "B" },
          { label: "product3", value: "C" }
        ]
      }
    ]
  });

  editor.on('preSubmit', function(e, data, action) {
    if (action !== 'remove') {
      var selectedValue = editor.field('code').val();
      var selectedText = editor.field('code').??;
    }
  });

how can get select filed text? ==> var selectedText = editor.field('code').??;

Answers

  • allanallan Posts: 63,516Questions: 1Answers: 10,472 Site admin
    editor.field('priority').input().children(':selected').text() 
    

    will get the label of the selected value. That uses the Editor field().input() method to get the select and then a little bit of jQuery to get the selected option and its text value.

    Allan

Sign In or Register to comment.