Skip to content

Instantly share code, notes, and snippets.

@caleywoods
Last active August 29, 2015 14:15
Show Gist options
  • Save caleywoods/8ca7b4f10cff0f856b2c to your computer and use it in GitHub Desktop.
Save caleywoods/8ca7b4f10cff0f856b2c to your computer and use it in GitHub Desktop.

http://imgur.com/a/G2o15

in the first photo I've clicked "Credit Memos" and it makes an ajax call even with the children already shown being present in the second photo. The second photo shows the data that is returned from the loading of the Tree Store that loads the initial set of folders in the first photo.

"TreeNode" in the php code is just a PHP object that mirrors the Ext Tree Node

<?php
// Create Credit Memos Folder
$creditMemos = new TreeNode();
$creditMemos->text = 'Credit Memos';
$creditMemos->id = 'creditmemos';
$creditMemos->expandable = true;
$creditMemos->expanded = false;
$creditMemos->cls = 'folder';
// Create sub folders for Open/Finalized CM's
$openCM = new TreeNode();
$openCM->text = 'Open';
$openCM->id = 'open/';
$openCM->expandable = true;
$openCM->expanded = false;
$openCM->cls = 'folder';
$finalCM = new TreeNode();
$finalCM->text = 'Finalized';
$finalCM->id = 'finalized/';
$finalCM->expandable = true;
$finalCM->expanded = false;
$finalCM->cls = 'folder';
// Add the Open and Finalized Folders into $creditMemos children
$creditMemos->children[] = $openCM;
$creditMemos->children[] = $finalCM;
Ext.define('whiteboard.store.yearbookinvoicer.SalesTree', {
extend :'Ext.data.TreeStore',
autoLoad : true,
root:{
expanded : true,
text : "Sales",
id : "data"
},
proxy: {
type : 'ajax',
url : '/ybkinvoicer/data/salestree',
reader: {
type: 'json',
root: 'data'
}
}
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment