Categories | Question details Back To List | ||
DHTMLXTree userdata truncation in firefox with loadXMLString I am attempting to load a large content section into a userdata section of tree node. In IE, the entire content is loaded and retrievable. In firefox, the data appears to be truncated at about 4K my entire data section was about 6K in length. this is my init code: tree=new dhtmlXTreeObject("treeboxbox_tree","100%","100%",0); tree.setImagePath("codebase/imgs/csh_bluebooks/"); tree.enableTreeLines("true"); tree.enableTreeImages("false"); tree.enableHighlighting(true); tree.enableCheckBoxes(0); tree.enableDragAndDrop(1); tree.setDragBehavior("sibling"); tree.enableMercyDrag(1); tree.attachEvent("onClick", tonclick); tree.attachEvent("onDrag", myfunc); tree.loadXMLString(xmldata); The xmldata looks something like this: <tree id="0"> <item id="page" text="page"> <userdata name="title">My Title</userdata> <userdata name="long_data_section"> -- long text data went here -- </userdata> </item> </tree> I have tried printing the xmldata right before the load call, and the entire data collection is there, and serailizeTree after. The serialize shows the data truncated. I have also ruled out the possibility that the issue was with the DOMParser through other tests. Are there any known limitations or work arounds for this issue? Answer posted by Support on Apr 07, 2008 04:25 >>I have also ruled out the possibility that the issue was with the DOMParser through other tests.
Firefox represent long text nodes as group of elements instead of one big text node. The only way to resolve issue - do next small modification in code of tree. Locate next string in code of dhtmlxgrid.js xmlPointer.prototype={ ... content:function(){return this.d.firstChild?this.d.firstChild.data:""; }, // <4k in FF and replace it with content:function(){var t=""; for (var i=0; i<d.childNodes.length; i++) t+=d.childNodes[i].data; return t; }, Answer posted by TomHj on Jul 11, 2008 11:45 I'm having this exact same problem. My grid has some rows with userdata over 4k in size. It works fine in IE but in FireFox 2 & 3, the userdata string is truncated at 4096. I used FireBug to verify that the full user data was really getting sent to the browser. I then searched this knowledge base and I was glad to find the above question and answer - but dismayed when I could not find the code dhtmlxgrid.js fragment referenced in Support's answer. I have tried the dhtmlxTreeGrid_pro_v15_71114 version as well as that latest dhtmlxTreeGrid_pro_v16_80512 version. What am I missing? Answer posted by Support on Jul 14, 2008 02:04 The snippet above was related to dhtmlxTree, latest version of grid uses different way to process incoming XML. dhtmlxgrid.js , line 4915 _process_xml_row:function(r, xml){ ... for (var i = udCol.length-1; i >= 0; i--) this.setUserData(r.idd,udCol[i].getAttribute("name"), udCol[i].firstChild?udCol[i].firstChild.data: ""); Can be replaced with for (var i = udCol.length-1; i >= 0; i--){ var t=""; for (var j=0; j<udCol[i].childNodes.length; j++) t+=udCol[i].childNodes[j].data; this.setUserData(r.idd,udCol[i].getAttribute("name"), t); } Answer posted by TomHj on Jul 14, 2008 11:12 Thanks - that solves the problem. Will this change be put into the next release or will I have to patch it? Answer posted by Support on Jul 15, 2008 01:55 The usage of such big userdata is pretty rare use-case, and the parsing of incoming data is a time critical part of code. So far, we not plan to add support of userdata greater than 4k as officially supported feature. |