Skip to content

Commit d654c8f

Browse files
committed
这样就可以支持访问JSON嵌套属性了
Flat JSON 扩展不行啊,破坏了原始数据,大概看了下还是从这里下手不会影响,这样可行的话就太好了
1 parent f65c2de commit d654c8f

File tree

1 file changed

+11
-2
lines changed

1 file changed

+11
-2
lines changed

src/bootstrap-table.js

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1335,6 +1335,15 @@
13351335
var that = this,
13361336
html = [],
13371337
data = this.getData();
1338+
1339+
function getItemField(item, field) {
1340+
var props = field.split('.');
1341+
var value = item;
1342+
for(var p in props) {
1343+
value = value[props[p]];
1344+
}
1345+
return value;
1346+
}
13381347

13391348
this.trigger('pre-body', data);
13401349

@@ -1410,7 +1419,7 @@
14101419

14111420
$.each(this.header.fields, function (j, field) {
14121421
var text = '',
1413-
value = item[field],
1422+
value = getItemField(item, field),
14141423
type = '',
14151424
cellStyle = {},
14161425
id_ = '',
@@ -1537,7 +1546,7 @@
15371546
index = $td[0].cellIndex,
15381547
field = that.header.fields[that.options.detailView && !that.options.cardView ? index - 1 : index],
15391548
colomn = that.columns[getFieldIndex(that.columns, field)],
1540-
value = item[field];
1549+
value = getItemField(item, field);
15411550

15421551
if ($td.find('.detail-icon').length) {
15431552
return;

0 commit comments

Comments
 (0)