bootstrap table editable行內(nèi)編輯select顯示empty問(wèn)題

把bootstrap-table-editable.js文件的,1355行

            column.formatter = function (value, row, index) {
              var result = Utils.calculateObjectValue(column, column._formatter, [value, row, index], value);
              result = typeof result === 'undefined' || result === null ? _this.options.undefinedText : result;
              $.each(column, processDataOptions);
              $.each(editableOptions, function (key, value) {
                editableDataMarkup.push(" ".concat(key, "=\"").concat(value, "\""));
              });
              var _dont_edit_formatter = false;

              if (column.editable.hasOwnProperty('noeditFormatter')) {
                _dont_edit_formatter = column.editable.noeditFormatter(value, row, index);
              }

              if (_dont_edit_formatter === false) {
                return "<a href=\"javascript:void(0)\"\n            data-name=\"".concat(column.field, "\"\n            data-pk=\"").concat(row[_this.options.idField], "\"\n            data-value=\"").concat(result, "\"\n            ").concat(editableDataMarkup.join(''), ">"+value+"</a>");
              }

              return _dont_edit_formatter;
            };

修改為:

column.formatter = function(value, row, index) {
                  var result = column._formatter ? column._formatter(value, row, index) : value;
                  $.each(column, processDataOptions);
                  $.each(editableOptions, function(key, value) {
                      editableDataMarkup.push(' ' + key + '="' + value + '"');
                  });
                  var _dont_edit_formatter = false;
                  if (column.editable.hasOwnProperty('noeditFormatter')) {
                      var process = column.editable.noeditFormatter(value, row, index);
                      if(!process.hasOwnProperty('class')){
                          process.class = '';
                      }
                      if(!process.hasOwnProperty('style')){
                          process.style = '';
                      }
                      _dont_edit_formatter = ['<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 + '"',
                          ' class="'+process.class+'" style="'+process.style+'"',
                          '>' + process.text+ '</a>'
                      ].join('');
                  }
                  if (_dont_edit_formatter === false) {
                      return ['<a href="javascript:void(0)" rel="external nofollow" rel="external nofollow" rel="external nofollow" ',
                          ' data-name="' + column.field + '"',
                          ' data-pk="' + row[_this.options.idField] + '"',
                          ' data-value="' + result + '"',
                          editableDataMarkup.join(''),
                          '>' + value + '</a>'
                      ].join('');
                  } else {
                      return _dont_edit_formatter;
                  }
              };

并在行內(nèi)editable中寫(xiě)一個(gè)函數(shù)noeditFormatter

                editable:{
                    type: 'select',
                    title: '部門(mén)',
                    source: users,
                    noeditFormatter: function (value,row,index) {
                        var zz
                        if(value!= null)
                            zz = value.username
                    var result={filed:"securityGuard",value:zz,class:"badge",style:"background:#333;padding:5px 10px;",text:'要顯示的內(nèi)容'};

                    return result;
                }

這樣把數(shù)據(jù)更新完畢刷新就行了

最后編輯于
?著作權(quán)歸作者所有,轉(zhuǎn)載或內(nèi)容合作請(qǐng)聯(lián)系作者
【社區(qū)內(nèi)容提示】社區(qū)部分內(nèi)容疑似由AI輔助生成,瀏覽時(shí)請(qǐng)結(jié)合常識(shí)與多方信息審慎甄別。
平臺(tái)聲明:文章內(nèi)容(如有圖片或視頻亦包括在內(nèi))由作者上傳并發(fā)布,文章內(nèi)容僅代表作者本人觀點(diǎn),簡(jiǎn)書(shū)系信息發(fā)布平臺(tái),僅提供信息存儲(chǔ)服務(wù)。

相關(guān)閱讀更多精彩內(nèi)容

友情鏈接更多精彩內(nèi)容