最近在研究 bootstrapTable-editable , 在編輯時出現了一些問題, 比如在行編輯時select的數據回顯, 代碼如下
$('#labelName').bootstrapTable({ pagination : false,//是否分頁 columns: [ { field: 'label', title: '標簽名稱' }, { field: 'key', title: '主鍵選擇', editable: { type: 'select', title: '主鍵選擇', mode: "inline", width: 150, source: function(row){ var result = []; var getData = $('#labelName').bootstrapTable('getData'), index = $(this).parents('tr').data('index'); console.log(getData[index].label) $.ajax({ url:aicKnowledge + 'update/getProperties', async: false, type: "get", data: { id:jumpId, label:getData[index].label }, success: function (datas, status) { if(datas.code == 600){ var items = datas.data; $.each(items, function (key,value) { result.push({ value:value, text:value }); }); } } }); return result; }, noeditFormatter: function (value, row, index) { // 解決展示為empty的問題 var process={filed:"key",value:value}; return ['<a href="javascript:void(0)" rel="external nofollow" rel="external nofollow" rel="external nofollow" ', ' data-name="'+process.filed+'"', ' data-pk="1"', ' data-value="' + process.value + '"', '>' + process.value + '</a>' ].join('');; } } } ], }