Bug - Accordion - ForEachItem when using loadStruct XML/JSON

Hi,
I have a full screen constructor init of a 3T layout using DHTMLX v4.0.3 Standard Edition
In cell “b” I have attached an accordion.

var menuAccordion = mainLayout.cells("b").attachAccordion();

I then use loadStruct to load the accordions structure as this is going to come from a database and needs to be dynamic.

menuAccordion.loadStruct("data/main-menu.php");

output:'{skin: "dhx_skyblue", multi_mode: true, icons_path: "./codebase/imgs/", items: [{id: "accItem_1", height: 150, icon: "book.png", text: "Main Page"},{id: "accItem_2", height: "*", icon: "book.png", text: "Site Navigation"}]}'; This all works fine and everything renders correctly.

The issue comes when I want to get the Ids of all the cells in the accordion

menuAccordion.forEachItem(function(cell){ console.log(cell.getId()); }); this does not work :frowning:

If I copy the JSON output from the ‘main-menu.php’ page and store that in a variable and use the following code instead.

var data = '{skin: "dhx_skyblue", multi_mode: true, icons_path: "./codebase/imgs/", items: [{id: "accItem_1", height: 150, icon: "book.png", text: "Main Page"},{id: "accItem_2", height: "*", icon: "book.png", text: "Site Navigation"}]}'; menuAccordion.loadStruct(data);then the forEachItem works and console log shows the accordion cell Ids correctly.

I have also tried outputting in XML from ‘main-menu.php’ and this to has the same problem…
I have looked through the forums but cant find anyone else having this issue.

please help

Please, provide us a demo, whic can reproduce this issue to inspect it
docs.dhtmlx.com/auxiliary_docs__ … pport.html

Hi Darya,

As requested a demo app for you.
please read the comments in the core.js file for explanation of how to replicate the issue as well as an error I found in some of the online documentation.

Kind Regards
my_demo.zip (496 KB)

Please, specify these lines depending on added comments :slight_smile:


Hi Darya,

please run 2 tests as per your attached picture.

  1. run the code as is with the web browsers console open you should see the cell ids output to the console.
  2. comment out lines 97 & 102 and un comment line 101 and you will no longer have the cell ids outputting to the console.

sorry for incorrect line numbers I must have written the comments before I clean out some of the other code on the page that does not apply to this bug.

You just need to get all items in callback :slight_smile:

menuAccordion.loadStruct("data/main-menu.php", function(){ menuAccordion.forEachItem(function(cell){ console.log(cell.getId()); }); });

Hi Darya,
works a treat… thank you… :smiley: :smiley: :smiley:

how did you go with the other comments i put in the code re: documentation errors?
did they make sense?

Oh, sorry, missed… ))
These three?
1. there is a typo - q<nodes.lengt; should be q<nodes.length;
2. nodes[q].getAttribute(“name”) should be nodes[q].children[0].getAttribute(“name”)
3. nodes[q].getAttribute(“value”) should be nodes[q].children[0].getAttribute(“value”)

Or something else?

yeah… thats them…

its the PHP / XML example found here.
http://docs.dhtmlx.com/api__dhtmlxajax_getsync.html

there is a typo in your documentation.
and the example as it was in the documentation did not work until I modified the code as presented in my comments.

It would also be nice if all the Constructor examples for all the dhtmlx widget objects in the documentation showed all available configuration options…

hope this feed back is of help to you.

Ok, thank you. We fixed it and will post correct version in the next docs update.