how can get editor.filed(x).text?
how can get editor.filed(x).text?
moonoo1
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
will get the label of the selected value. That uses the Editor
field().input()
method to get theselect
and then a little bit of jQuery to get the selectedoption
and its text value.Allan