我有一个 JSON 值,它有多个用逗号分隔的值。有没有办法在 dom 中呈现它作为选择下拉输入?
这是我的标记的更详细视图。
HTML
<h1>JSON Grid Edit</h1>
<table cellpadding="0" cellspacing="0" border="0" class="dt display" id="json-table-edit" contenteditable="true" onKeyUp="editValue(this.id);">
<thead>
<tr>
<th width="25%">Setting</th>
<th width="75%">Value</th>
</tr>
</thead>
<tbody>
</tbody>
<tfoot>
<tr>
<th>Setting</th>
<th>Value</th>
</tr>
</tfoot>
</table>
JSON
{
"allconfig": {
"card.inserted": {
"value": "Inserted, Not Inserted",
},
"card.cisproc": {
"value": "Processed",
}
}
}
查询
$.getJSON('json/ione-edit.json', function (data) {
var newJson = [];
var myJson = data;
$.each(myJson.allconfig, function (key, value) {
var rowArray = [];
rowArray.push(key);
$.each(myJson.allconfig[key], function (key1, value1) {
rowArray.push(value1);
});
newJson.push(rowArray);
});
$('#json-table-edit').dataTable({
"bJQueryUI": true,
"bStateSave": true,
"sPaginationType": "full_numbers",
"bProcessing": true,
"oLanguage": {
"sLengthMenu": ' <select>' + '<option value="10" selected="selected">Filter</option>' + '<option value="10">10</option>' + '<option value="20">20</option>' + '<option value="30">30</option>' + '<option value="40">40</option>' + '<option value="50">50</option>' + '<option value="-1">All</option>' + '</select>'
},
"aaData": newJson
});