KnockoutJS - nested data, loading children

I am very new to knockouts - having worked through the textbooks and I made a good start. I have an application that seems well suited to CO. In this I need to populate the table with data from JSON. This data is nested and can be nested at any depth, but my API will only ever return data at two levels.

eg.

  • Node 1
    • Node a
    • Node B

I managed to load the data into my desk, fine. I took this one more step and nesting support. I have a requirement that if Node has children, it can be entered under Node in the table.

An example of this might be ...

  • Node 1 (HasChildren)
    • Node a
    • Node B (HasChildren)

Node B 'HasChildren', Node B. API, Node B

  • Node 1
    • Node A
    • Node B
      • Node B1
      • Node B2

- , 1 node. 2, , (AddChild). , , ViewModel.

, , .

!

... ( , "", , !)

http://jsfiddle.net/8k6pj/1/ - (18 2012 .)

http://jsfiddle.net/8k6pj/6/ -

!

p.s , , , , , .

, postback , , . , , ObservableArray, .

+3
2

, , , , , , , .

, , , .

jquery, , , Crew/Component.

<td rowspan="3">
    <a data-bind="click: open">Open</a>
    <a>Save</a>
</td>

, addChild . , Crew Crews, , Crews .

, Models .

http://jsfiddle.net/madcapnmckay/fdb5r/2/

FYI. - "", . , , , . .

, . , , .

http://jsfiddle.net/madcapnmckay/xxGam/

, .

+2

All Articles