1
我想通過數據表編輯器部分的動態值,它必須選擇,如果我們點擊數據表中的編輯按鈕。這裏是我的代碼:如何在數據表編輯器中動態地傳遞選擇框的值?
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;
});
}