Skip to content

Commit

Permalink
Merge pull request wenzhixin#1860 from ludup/develop
Browse files Browse the repository at this point in the history
Rendering detail view directly with detailFormatter
  • Loading branch information
wenzhixin committed Jan 15, 2016
2 parents 7965419 + 591025f commit 471f1c3
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 6 deletions.
4 changes: 2 additions & 2 deletions docs/_i18n/en/documentation/table-options.md
Original file line number Diff line number Diff line change
Expand Up @@ -408,8 +408,8 @@ The table options are defined in `jQuery.fn.bootstrapTable.defaults`.
<td>detailFormatter</td>
<td>data-detail-formatter</td>
<td>Function</td>
<td>function(index, row) {<br>return '';<br>}</td>
<td>Format your detail view when <code>detailView</code> is set to <code>true</code>.</td>
<td>function(index, row, element) {<br>return '';<br>}</td>
<td>Format your detail view when <code>detailView</code> is set to <code>true</code>. Return a String and it will be appended into the detail view cell, optionally render the element directly using the third parameter which is a jQuery element of the target cell.</td>
</tr>
<tr>
<td>searchAlign</td>
Expand Down
11 changes: 7 additions & 4 deletions src/bootstrap-table.js
Original file line number Diff line number Diff line change
Expand Up @@ -1692,10 +1692,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();
});
Expand Down

0 comments on commit 471f1c3

Please sign in to comment.