bootstrap table實現x-editable的行單元格編輯及解決數據Empty的問題


最近在研究 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('');;
                    }
                } 
	}
  ],
}

  


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM