TreeNodes.updateFrom

Syntax

updateFrom (jsonData)

Parameters

jsonData. Array of JSON objects that have fields corresponding to properties of the class PP.Ui.TreeNode.

Description

The updateFrom method inserts an array of tree items to the node deleting all children of the node. It reserves items' state (that is, properties set for these items), initializing them by the key.

Comments

The difference between the updateFrom and loadFrom method lies in the following: updateFrom  inserts items in the same order they are stored in JSON, if the source node and the replaced one have matching keys, no property except for Text is changed for the node, while the loadFrom method sets values of all unspecified properties to default values.

Example

To execute this example, the page must contain the TreeList component named treeList (seebsp; Example of Creating the TreeList Component). The newSettings variables contains a JSON object which stores description of component nodes:

NOTE. Set a key for each of the nodes.

var newSettings = [

 {

   Text: "Node 1",

   Columns: ["10", "12", "34"],

   Selected: true,

   CanSelect: true,

   Checked: true,

   Key: 10

 },

 {

   Text: "Node 2",

   Columns: ["12", "123", "33"],

   Selected: false,

   CanSelect: true,

   Checked: false,

   Key: 11

 },

 {

   Text: "Node 3",

   Columns: ["33", "67", "65"],

   Selected: false,

   CanSelect: true,

   Checked: true,

   Key: 12

 }]

Refresh the tree:

treeList.getNodes().updateFrom(newSettings)

 

After executing the example the tree looks as follows:

See also:

TreeNodes