浏览代码

Adds a third parameter to detailFormatter method passing the jQuery element of the new cell that will contain the detail view. This allows a developer to render directly into the cell which can be advantagous in some circumstances. If the method returns with the element still empty the string returned from detailFormatter will be appended, maintaining backwards compatibility with previous versions.

Lee David Painter 10 年之前
父节点
当前提交
6e3d968c6d
共有 1 个文件被更改,包括 7 次插入4 次删除
  1. 7 4
      src/bootstrap-table.js

+ 7 - 4
src/bootstrap-table.js

@@ -1667,10 +1667,13 @@
                 that.trigger('collapse-row', index, row);
             } else {
                 $this.find('i').attr('class', sprintf('%s %s', that.options.iconsPrefix, that.options.icons.detailClose));
-                $tr.after(sprintf('<tr class="detail-view"><td colspan="%s">%s</td></tr>',
-                    $tr.find('td').length, calculateObjectValue(that.options,
-                        that.options.detailFormatter, [index, row], '')));
-                that.trigger('expand-row', index, row, $tr.next().find('td'));
+                $tr.after(sprintf('<tr class="detail-view"><td colspan="%s"></td></tr>', $tr.find('td').length));
+                var $element = $tr.next().find('td');
+                var content = calculateObjectValue(that.options, that.options.detailFormatter, [index, row, $element], '');
+                if($element.length == 1) {
+                  $element.append(content);
+                }
+                that.trigger('expand-row', index, row, $element);
             }
             that.resetView();
         });