Bootstrap没有显示来自REST端点的数据?

时间:2016-12-02 06:53:51

标签: javascript jquery bootstrap-table

使用bootstrap表命中我的一个REST端点,但我们现在显示的数据完全显示。这就是我正在使用的内容(请参阅小提琴:https://jsfiddle.net/vgwod3fb/):

1

根据我所看到的情况,我从端点获取正确的数据,但表中没有显示正确的数据。请参阅下面的回复:

enter image description here

失败的地方是$('#data-table').bootstrapTable({ url: '/rest/endpoint, striped: true, iconSize: 'btn-sm', cache: false, search: true, searchOnEnterKey: true, searchText: 'Search for a member...', columns: [ { checkbox: true, field: 'check', clickToSelect: true, searchable: false }, { field: 'email', title: 'Name', sortable: true, clickToSelect: false }, { field: 'role', title: 'Type', sortable: true, clickToSelect: false }, { field: 'actions', title: 'Actions', sortable: false, clickToSelect: false, formatter: function () { return '<img class="control" src="/assets/images/delete.svg" alt="Delete">'; } } ] }); 方法:

enter image description here

如果我在控制台中重置数据值,数据将正确显示:

getData()

有什么想法吗? Bootstrap Table是否期望响应完全与列相同的结构?

更新1

我尝试过使用这种方法,但仍无济于事......这样一个广泛使用的小部件绝对是一个停止显示的问题。

我使用ajax调用得到了数据,就像表一样,我清理了数据,所以我们有:

 data = this.options.data;

以下是我在下面使用的代码:

 {
      checkbox: true,
      email: 'user@foo.com',
      role: 'foo',
      actions: undefined
 }

1 个答案:

答案 0 :(得分:0)

想出来!它与:

有关
 searchText: 'Search for a member...',

这将使用内容自动填充搜索栏,并尝试根据该搜索词找到用户。删除此属性解决了这个问题。