Skip to content

Instantly share code, notes, and snippets.

@jesandco
Last active December 14, 2015 21:49
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jesandco/5153436 to your computer and use it in GitHub Desktop.
Save jesandco/5153436 to your computer and use it in GitHub Desktop.
Simple replacement check-tree.js file that uses ASN Common Core State Standards manifest with CORS enabled to select specific standards. http://dev.sencha.com/deploy/ext-4.0.0/examples/tree/check-tree.html
/*
This file is part of Ext JS 4
Copyright (c) 2011 Sencha Inc
Contact: http://www.sencha.com/contact
GNU General Public License Usage
This file may be used under the terms of the GNU General Public License version 3.0 as published by the Free Software Foundation and appearing in the file LICENSE included in the packaging of this file. Please review the following information to ensure the GNU General Public License version 3.0 requirements will be met: http://www.gnu.org/copyleft/gpl.html.
If you are unsure which license is appropriate for your use, please contact the sales department at http://www.sencha.com/contact.
*/
Ext.require([
'Ext.tree.*',
'Ext.data.*',
'Ext.window.MessageBox'
]);
Ext.onReady(function() {
//Define a new 'asn' data model with certain fields from the manifest. Full list of available fields - http://jesand.co/Y9CeRR
Ext.define('asn', {
extend: 'Ext.data.Model',
fields : ['text', 'id']
});
//ASN manifest doesn't contain a field called 'checked', so let's add it on-the-fly
asn.prototype.fields.add(new Ext.data.Field({ name: 'checked', defaultValue: false}));
//add CORS support for ASN manifest request
Ext.Ajax.useDefaultXhrHeader = false;
Ext.Ajax.cors = true;
var store = Ext.create('Ext.data.TreeStore', {
model: 'asn',
proxy: {
type: 'ajax',
url: 'http://s3.amazonaws.com/asnstatic/data/manifest/D10003FB.json' //ASN manifest location
},
sorters: [{
property: 'leaf',
direction: 'ASC'
}, {
property: 'text',
direction: 'ASC'
}]
});
var tree = Ext.create('Ext.tree.Panel', {
store: store,
rootVisible: false,
useArrows: true,
frame: true,
title: 'Check Tree',
renderTo: 'tree-div',
width: 500,
height: 250,
dockedItems: [{
xtype: 'toolbar',
items: {
text: 'Get checked nodes',
handler: function(){
//get the ASN URI from checked
var records = tree.getView().getChecked(),
names = [];
Ext.Array.each(records, function(rec){
names.push(rec.get('id'));
});
Ext.MessageBox.show({
title: 'Selected Nodes',
msg: names.join('<br />'),
icon: Ext.MessageBox.INFO
});
}
}
}]
});
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment