ExtJS 4: TreePanel From Uploaded Xml File Without Xml Attributes

Posted By Vitaliy | March 09, 2013 | ExtJS 4.1.1
0 3760
​Xml file sample here.

Js Code

var form = win.down('form').getForm();
if (form.isValid()) {
    form.submit({
        url: '/upload/xml2',
        waitMsg: 'Uploading your xml file...',
        success: function (f, a) {
            var result = a.result,
                data = result.data,
                store = tree.getStore();

            win.close();

            store.setRootNode(data);
            tree.expandAll();
        },
        failure: function (f, a) {
            Ext.Msg.alert('Failure', a.result.msg);
        }
    });
}
            

ExtJS 4: TreePanel From Uploaded Xml File

Posted By Vitaliy | February 24, 2013 | ExtJS 4.1.1
0 4079
​Xml file sample here.

Js Code

var form = win.down('form').getForm();
if (form.isValid()) {
    form.submit({
        url: '/upload/xml',
        waitMsg: 'Uploading your xml file...',
        success: function(f, a) {
            var result = a.result,
                data = result.data,
                store = tree.getStore();

            win.close();

            store.setRootNode(data);
            tree.expandAll();
        },
        failure: function(f, a) {
            Ext.Msg.alert('Failure', a.result.msg);
        }
    });
}
            

How To Reload Window Content

Posted By Vitaliy | April 03, 2012 | ExtJS 4.0.7
1 4373
Reply to thread

Js Code

Ext.widget('window', {
	title: 'Test window',
	autoShow: true,
	width: 300,
	height: 150,
	bodyStyle: { 'background-color': '#FFFFFF', 'padding': '10px' },
	autoLoad: { url: '/postdata/getcontent/1' },
	tbar: [{
		text: 'Reload',
		handler: function () {
			var win = this.up('window');
			win.loader.load(win.autoLoad.url);
		}
	}, {
		text: 'Reset',
		handler: function () {
			var win = this.up('window');
			win.update('<b>Init</b> content');
		}
	}]
});
            

ExtJS 4 MVC Application Architecture

Posted By Vitaliy | April 01, 2012 | ExtJS 4.0.7
0 13321
This post is a demo for MVC Architecture Guide

Note: In your app you should include only one script reference /scripts/app/app.js
All other scripts will be loaded by Ext.Loader
Sources in VS 2010 Solution

Js Code

// /scripts/app/controller/Users.js
Ext.define('AM.controller.Users', {
	extend: 'Ext.app.Controller',
	stores: [
		'Users'
	],
	models: [
		'User'
	],
	views: [
		'user.List',
		'user.Add',
		'user.Edit'
	],
	init: function () {
		this.control({
			'userlist': {
				itemdblclick: this.editUser,
				removeitem: this.removeUser
			},
			'userlist > toolbar > button[action=create]': {
				click: this.onCreateUser
			},
			'useradd button[action=save]': {
				click: this.doCreateUser
			},
			'useredit button[action=save]': {
				click: this.updateUser
			}
		});
	},
	editUser: function (grid, record) {
		var view = Ext.widget('useredit');
		view.down('form').loadRecord(record);
	},
	removeUser: function (user) {
		Ext.Msg.confirm('Remove User', 'Are you sure?', function (button) {
			if (button == 'yes') {
				this.getUsersStore().remove(user);
			}
		}, this);
	},
	onCreateUser: function () {
		var view = Ext.widget('useradd');
	},
	doCreateUser: function (button) {
		var win = button.up('window'),
			form = win.down('form'),
			values = form.getValues(),
			store = this.getUsersStore();
		if (form.getForm().isValid()) {
			store.add(values);
			win.close();
		}
	},
	updateUser: function (button) {
		var win = button.up('window'),
			form = win.down('form'),
			record = form.getRecord(),
			values = form.getValues(),
			store = this.getUsersStore();
		if (form.getForm().isValid()) {
			record.set(values);
			win.close();
		}
	}
});