Get Values from selected row treetable with its child

how to get values from selected row treetable with its child ??
this is my code :

https://snippet.webix.com/7pd4wges

when I use getSelectedItem() its only return parent row values only.

Tagged:

Comments

  • Hello @frizky,

    how to get values from selected row treetable with its child ??

    You can use the getBranch() method of the inner TreeStore to get all of the child items of a specific item. Please take a look at the following example: https://snippet.webix.com/r4gq6onj.

  • edited December 2019

    thx @Dzmitry for reply. I have tried this getBranch() method before.
    But it not fulfill my requirement yet.

    Is it possible to return as first json data format loaded into treetable?

    example from json data

    var small_film_set = [
        { "id":"1", "value":"The Shawshank Redemption", "open":true, "data":[
          { "id":"1.1", "value":"Part 1", "chapter":"alpha"},
          { "id":"1.2", "value":"Part 2", "chapter":"beta", "open":true, "data":[
            { "id":"1.2.1", "value":"Part 1", "chapter":"beta-twin"},
            { "id":"1.2.2", "value":"Part 1", "chapter":"beta-twin"}
          ]},
          { "id":"1.3", "value":"Part 3", "chapter":"gamma" }
        ]},
    
        { "id":"2", "value":"The Godfather", "data":[
          { "id":"2.1", "value":"Part 1", "chapter":"alpha" },
          { "id":"2.2", "value":"Part 2", "chapter":"beta" }
        ]}
      ];
    

    when I click parent id "1" and it return data

    "{ "id":"1", "value":"The Shawshank Redemption", "open":true, "data":[
          { "id":"1.1", "value":"Part 1", "chapter":"alpha"},
          { "id":"1.2", "value":"Part 2", "chapter":"beta", "open":true, "data":[
            { "id":"1.2.1", "value":"Part 1", "chapter":"beta-twin"},
            { "id":"1.2.2", "value":"Part 1", "chapter":"beta-twin"}
          ]},
          { "id":"1.3", "value":"Part 3", "chapter":"gamma" }
        ]}"
    
  • Is it possible to return as first json data format loaded into treetable?

    I don't quite get what you mean by this, do you need to return the whole dataset that was parsed inside the component? If so, please check this example: https://snippet.webix.com/b2wrlazy. Otherwise, the format is exactly the same between the 2 provided datasets.

  • edited December 2019

    sorry for ambigous sentence. Yes, your answer is almost right.
    in previous comment I have two top parent of dataset with its child.

    1st:

    { "id":"1", "value":"The Shawshank Redemption", "open":true, "data":[
          { "id":"1.1", "value":"Part 1", "chapter":"alpha"},
          { "id":"1.2", "value":"Part 2", "chapter":"beta", "open":true, "data":[
            { "id":"1.2.1", "value":"Part 1", "chapter":"beta-twin"},
            { "id":"1.2.2", "value":"Part 1", "chapter":"beta-twin"}
          ]},
          { "id":"1.3", "value":"Part 3", "chapter":"gamma" }
        ]}
    

    2nd:

    { "id":"2", "value":"The Godfather", "data":[
          { "id":"2.1", "value":"Part 1", "chapter":"alpha" },
          { "id":"2.2", "value":"Part 2", "chapter":"beta" }
        ]}
    

    I want to edit 1st dataset so I select top parent of row on treetable in this case ` "id":"1", "value":"The Shawshank Redemption" '.
    After clicking "Edit New Button", I want to get only selected row data with its child in this case 1st of dataset but in the same structure as json format as I written above.
    In your last example it will return all dataset.

    Is it possible ?

    I hope you understand my sentences. I apologize before & after.

  • edited December 2019

    I hope you understand my sentences

    Yes, thank you for the clarification, the best I can think of would be to filter the component first and use the same serialize() method from the previous example (by default, only the filtered dataset will be serialized). Additionaly, you can remove any additional properties that were added to the dataset during the initial parsing through the scheme - https://snippet.webix.com/3vn93vhu.

  • edited December 2019

    thx @Dzmitry, :wink:

Sign In or Register to comment.

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!