jQuery UI Widgets › Forums › Navigation › Tree › I get cyclic object value with using jqtree
Tagged: ajax, cyclic object, Durandal, jqxtree, knockout tree, knockoutjs
This topic contains 4 replies, has 3 voices, and was last updated by reenawani 7 years, 9 months ago.
-
Author
-
I used jqtree in durandal with knockoutJS, i put my code in the knockout attached function.
tree loads sometimes with type error : cyclic object value.
sometimes does not show and i should clear cache many times then it show!
this is my code:function TreeNode(id, parentid, text, value) {
var self = this;
self.id = id;
self.parentid = parentid;
self.text = text;
self.value = value;
}
function toId(input) {
return input == null ? “-1″ : input + ”;
}
$.getJSON(“api/Solution/GetTree”)
.done(function (tree) {
var nodes = [];
for (var i in tree) {var node = tree[i];
nodes.push(new TreeNode(
toId(node.FldID),
toId(node.FldParentID),
node.FldTitle,
node.FldValue));
}var source =
{
datatype: “json”,
datafields: [
{ name: ‘id’ },
{ name: ‘parentid’ },
{ name: ‘text’ },
{ name: ‘value’ }
],
id: ‘id’,
rtl: true,
localdata: nodes
};
// create data adapter.
var dataAdapter = new $.jqx.dataAdapter(source);
// perform Data Binding.
dataAdapter.dataBind();var records = dataAdapter.getRecordsHierarchy(‘id’, ‘parentid’, ‘items’, [{ name: ‘text’, map: ‘label’ }]);
self.treeNodes(records);
});Hello reyhan,
Please share where exactly the error is thrown in your code (on which line from the above). Could this cyclic object be the result of your Ajax call and not be directly related to jqxTree? Moreover, the self variable does not seem to be defined in the scope of the done callback function.
Best Regards,
DimitarjQWidgets team
http://www.jqwidgets.com/Hello Dimitar
thanks for your reply 🙂
description of error :
TypeError: cyclic object value knockout-3.4.0.debug.js:591:20
ko.utils.stringifyJson http://localhost:8192/Scripts/knockout-3.4.0.debug.js:591:20
ko.toJSON http://localhost:8192/Scripts/knockout-3.4.0.debug.js:2324:16
c.jqwidgets.knockout/L.update/< http://localhost:8192/Scripts/JQwidget/jqxknockout.js:7:1803
.each http://localhost:8192/Scripts/jquery-1.10.2.js:679:14
c.jqwidgets.knockout/L.update http://localhost:8192/Scripts/JQwidget/jqxknockout.js:7:1507
applyBindingsToNodeInternal/</< http://localhost:8192/Scripts/knockout-3.4.0.debug.js:3318:33
computedFn.evaluateImmediate_CallReadThenEndDependencyDetection http://localhost:8192/Scripts/knockout-3.4.0.debug.js:2142:103
computedFn.evaluateImmediate_CallReadWithDependencyDetection http://localhost:8192/Scripts/knockout-3.4.0.debug.js:2114:24
computedFn.evaluateImmediate http://localhost:8192/Scripts/knockout-3.4.0.debug.js:2078:13
computedFn.evaluatePossiblyAsync http://localhost:8192/Scripts/knockout-3.4.0.debug.js:2044:13
bound self-hosted
ko_subscribable_fn.notifySubscribers http://localhost:8192/Scripts/knockout-3.4.0.debug.js:1320:25
observableFn.valueHasMutated http://localhost:8192/Scripts/knockout-3.4.0.debug.js:1529:36
observable http://localhost:8192/Scripts/knockout-3.4.0.debug.js:1495:17
mainModel/< http://localhost:8192/App/viewmodels/index.js:164:25
jQuery.Callbacks/fire http://localhost:8192/Scripts/jquery-1.10.2.js:3062:10
jQuery.Callbacks/self.fireWith http://localhost:8192/Scripts/jquery-1.10.2.js:3174:7
done http://localhost:8192/Scripts/jquery-1.10.2.js:8249:5
.send/callback http://localhost:8192/Scripts/jquery-1.10.2.js:8792:8self works with jqxgrid in other file.
Hello reyhan,
It is possible that the tree object received by getJSON in done is cyclic or that the cyclic object is actually nodes (as a result of its creation with
new TreeNode
). Either way, this does not seem to be an issue directly related to jqxTree.Best Regards,
DimitarjQWidgets team
http://www.jqwidgets.com/informative post
-
AuthorPosts
You must be logged in to reply to this topic.