Categories | Question details Back To List | ||
treegrid loading Hi, I have a quite complex problem, I'll try to give you precise information. I want to represent my local file system in a treegrid. Each file or directory id is its absolute path. I'm using a dhtmlxtreegrid which uses tree.loadXML("myfile.xml"); and tree.kidsXmlFile="myfile.xml"; Before loading the tree, I catch the onXLS event. In this event, I launch an applet and give it as an argument the id of the clicked row (or "0" if I want to build the root node). The applet builds a xml string representing my filesystem. For example, I give the id "c:\" parameter to the applet and it builds a xml string containing all files and directories of the C: volume. Then, the applet calls a JSP page passing it a POST variable which is the xml string. The JSP page modifies the xml string to convert it into a xml string which can be used to load the treegrid. Then, the JSP page creates "myfile.xml" on the server and copy the new xml string into it. By using this method I can browse my local file system. The problem is that sometimes (randomly), I have a "duplicateid" error. It's weird because myfile.xml is well created and the content is right but it seems that the treegrid uses the previous xml file content. I tried to clear the cache files on IE : still the same problem I tried to add an argument to myfile.xml like myfile.xml?uid=new Date()..... to prevent caching : still the same problem. I thought that by catching the onXLS event I could have done my trick with my applet and my JSP before my treegrid was reloaded but it seems that something is going wrong with that. Do you have any information that could help me about onXLS event or the way the treegrid is reloaded using the kidsXmlFile property ? Thanks and sorry for this long message (hope it is not so hard to understand, it was not easy to explain :-) Answer posted by Support on Mar 26, 2008 03:46 The problem can be caused by event concurrency, in case of described logic request of new file can be received before file physically saved to filesystem, so previous content will be grabbed The common solution for dynamical loading - usage of server side scritps ( JSP in you case ) instead of static XML tree.loadXML("myfile.jsp"); tree.kidsXmlFile="myfile.jsp"; and in JSP file built XML string and output it to stdout In your scenario you are using pretty complex approach, instead of using both applet and JSP you can use a) applet only, and using loadXMLString to load XML string directly from applet or b) JSP only , and built XML dynamically as described above Answer posted by A.D. on Mar 26, 2008 04:29 Thanks for your answer. About your first advice, applet only : if my applet builds a xml string, I understand that I can use loadXMLString but how do you use dynamical loading (with kidsXmlFile) with a string ? Is it possible to give a xml string to the kidsXmlFile property instead of a file ? About your second advice, jsp only : I need an applet to avoid security problems when I try to read my local files system. Answer posted by Support on Mar 26, 2008 10:55 There is no built in support for dynamical loading from XML string, but it can be easily adjusted dhtmlxtreegrid.js , line 201 this.loadXML(this.kidsXmlFile+""+s+"id="+r.id); can be replaced with any code which will build xml string and loads it var xml = some_custom_method(id); this.loadXMLString(xml); |