This topic explains, with code examples, how to retrieve the transaction log about adding and removing nodes in the igTree
™ control.
The following topics are prerequisites to understanding this topic:
igTree
control programmatically.This topic contains the following sections:
Transaction log stores information about added or removed nodes from igTree
. The information is stored in an array, which contains JSON objects. Each JSON object has a type of operation (a property with addnode
and removenode
string values) and node data such as node text. The igTree
control supports retrieving that transaction log. Retrieving the transaction log is done with the transactionLog method. This method returns the JSON object containing the type of operation and the node data.
The code in this example demonstrates retrieving the transaction log and parsing it to HTML output. The HTML output contains the type of operation – whether the nodes have been added or removed and the node text.
To complete the procedure, you need:
igTree
control bound to a data sourceigTree
.This preview picture demonstrates the transaction log retrieved with the code in this example and then converted to HTML and displayed beneath the tree to which it pertains.
Place this code in the placeholder for displaying the transaction log in the HTML page.
In JavaScript:
// parsing transaction log arguments to a string
function parseData(data) {
var string = "", i;
if (data.length) {
for (i = 0; i < data.length; i++) {
string += data[i].Text + (i < data.length - 1 ? ", " : "");
}
} else {
string += data.Text;
}
return string;
}
var log = $("#tree").igTree("transactionLog");
var html = "";
for (i = 0; i < log.length; i++) {
html += "<p>" + log[i].type + " " + parseData(log[i].tdata.data)
+ "</p>";
}
The following topics provide additional information related to this topic.
API Links (igTree): This topic provides links to the jQuery and MVC API of the igTree control.
Adding and Removing Nodes Overview and Examples (igTree): This topic explains, with code examples, how to add and remove nodes of igTree
control programmatically.
The following samples provide additional information related to this topic.
igTree
API.View on GitHub