ソースを参照

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);
                 that.trigger('collapse-row', index, row);
             } else {
             } else {
                 $this.find('i').attr('class', sprintf('%s %s', that.options.iconsPrefix, that.options.icons.detailClose));
                 $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();
             that.resetView();
         });
         });