我正在尝试传递数据表编辑器部分的动态值,如果我们单击数据表中的编辑按钮,则必须选择它。这是我的代码:
var editor; // use a global for the submit and return data rendering in the examples
$(document).ready(function() {
editor = new $.fn.dataTable.Editor({
ajax: 'staff-array.php',
table: '#example',
fields: [{
label: 'Project ID:',
name: 0
}, {
label: 'Description:',
name: 1
}, {
label: 'Notes:',
name: 2
},
{
label: 'Status:',
name: 3,
type: "select",
"ipOpts": getStateList()
}]
});
这是获取选择框值的函数:
function getStateList() {
var aStateList = new Array();
$.ajax({
url: 'server_processing.php',
type: 'POST',
dataType: 'json'
}).done(function(json){
for (var a = 0; a < json.length; a++) {
aStateList[a] = { "label": json[a][0], "value" : json[a][1] };
}
return aStateList;
});
}