Skip to content

Hierarchy is just an array.

jefhu edited this page Jul 27, 2015 · 1 revision

[a, [b], [c,[c1, c2]],[d]] can be written as
0 a (indentLevel =0)
1     b (previousLine=a, nextLine=c1, parent=a, indentLevel =1)
2     c (previousLine=b, nextLine=c1, parent=a, , indentLevel =1)
3         c1(previousLine=c, nextLine=c2, parent=c, , indentLevel =2)
4         c2 (previousLine=c1, nextLine=d, parent=c, , indentLevel =2)
5     d (previousLine=c2, nextLine=null, parent=a, , indentLevel =1)

datastore widget has API set to manipulate data. For example, you want get the data sub-tree from c.

  1. c's row index is 2 and column index is 1. Start looping from row-2 down vertically.
  2. Row-3 is c1. c1's row-index is 3, column index is 2. As c1_column-index < c_column-index. So c1 is in B's subtree. The sample applies to c2.
  3. Row-5 is d. c's column-index = d's column-index. Therefore, C is sibling of d. (b, c, d are sibling as they have the same indentLevel value.)

Final return is a list [B, b1, b2].

Please see jquery.ui.datastore.js and jquery.ui.treeintable.js APIs for details. test_jquery_treetableDnD.html line 53, "treeintableWidget3.onRowSelect=function(trNode){...}" has a lot of sample codes.

Clone this wiki locally