kawanoshinobu/Ext.ux.AccordionList — pull request #27 by Odi55555 (2013-12-19 15:58:57+00:00)
Title: Load child nodes when expanding the node and the children are not loaded

I want to fix my reported issue #26.
After some debugging and comparison to the nested list code I had to remove the onNodeBeforeExpand override. Because this function checks if the children of a node are loaded or not. The treestore loads the node's children for us, if they're not loaded.

The next problem was the sort order. The treestore adds the new records at the end of its data and items array. This is not a problem for a nestedlist, because it creates a new list store for every tree layer. However the AccordionList has only one list and displays the items in the same order like they're stored at the items array of the treestore. Every time a node is expanded the node's children are added to the items array from the data array and vice versa when a node is collapsed.

In my opinion there's a bug at sencha's add method for a treestore, because it tries to add the new records at the right index, but it fails at the insertAll method of Ext.util.Collection. This method gets the correct index for the data array, but not for the items array where it inserts the new records. Because the index is too high (data array length > items array length, if not every node is expanded), it calls the addAll method. This method just pushes the new records add the end of the array and insertAll is skipped. I just added an addrecords listener and fix the sort order if necessary.

My other commits are just fixing some jshint errors and beautifying the code.