Bootstrap table 父子表默认展开

  最近系统用了Bootstrap table ,处于慢慢探索中。

后来要求table加载默认展开一级数据,如图 ,摸索了一阵子,功能是实现了,一开始

尝试使用table渲染完成事件 onPostBody :function (index, row, $detail) {

InitSubTable(index, row, $detail);

} ,好像没用,报错。 后来发现有个展开方法调用 $("#tb_stationInfo").bootstrapTable('expandAllRows'); 但是写在哪? 写在table 刷新之后

   $("#tb_stationInfo").bootstrapTable('refresh'); $("#tb_stationInfo").bootstrapTable('expandAllRows'); 无效。

想到是不是table 还没渲染完成。后来将展开方法封装成方法,延时调用。function expand (){ $("#tb_stationInfo").bootstrapTable('expandAllRows'); };

$("#tb_stationInfo").bootstrapTable('refresh'); setTimeout(expand ,1000); 初步达成,但是万一网速很卡,还是会出现问题。

最后想到将展开方法写到最初onPostBody 事件中,好像是可以的。

注:这是自己摸索的,不知道有没有官方的使用方法,有的话,望告知,感激不尽。

Bootstrap table 父子表默认展开