简体   繁体   English

数据表 - 扩展和折叠嵌套行时遇到问题

[英]Datatables - Trouble with expanding and collapsing nested rows

I am using datatables and wanted to represent hierarchical JSON data in a grid. 我正在使用数据表,并希望在网格中表示分层JSON数据。 I got the data to display hierarchically in the datatable through ajax, but I am having trouble with javascript implementing the expanding and collapsing of the rows. 我通过ajax将数据分层显示在数据表中,但是我在使用javascript实现扩展和折叠行时遇到了麻烦。

Please take a look at this JSBin and try expanding and collapsing and you will see the issue: 请看一下这个JSBin并尝试扩展和折叠,你会看到这个问题:

http://live.datatables.net/qedufunu/1/edit http://live.datatables.net/qedufunu/1/edit

The behavior should be like any hierarchical data (like the windows explorer): 行为应该像任何分层数据(如Windows资源管理器):

  1. When the grid loads, it should display first level rows with the expand icon. 加载网格时,它应显示带有展开图标的第一级行。
  2. When the top level expand button is clicked, it should open second level rows for the same parent with an expand button (if there are 3rd level rows). 单击顶级展开按钮时,它应该使用展开按钮打开同一父级的第二级行(如果有第3级行)。
  3. When the second level expand button is clicked, it should open the third level rows. 单击第二级展开按钮时,它应打开第三级行。

Please take a look and suggest any JS changes. 请查看并建议任何JS更改。 Please feel free to modify the fiddle. 请随意修改小提琴。

Thanks. 谢谢。

Okay. 好的。 I fixed it myself. 我自己修好了。 For folks who need a solution for nested rows in datatable, this should help immensely. 对于需要在数据表中嵌套行的解决方案的人来说,这应该会有很大帮助。

http://live.datatables.net/qedufunu/2/edit http://live.datatables.net/qedufunu/2/edit

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM