ExtJS 4: TreePanel From Uploaded Xml File Without Xml Attributes

Posted By Vitaliy | March 09, 2013 | ExtJS 4.1.1
0 3105
​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 Xml String

Posted By Vitaliy | February 24, 2013 | ExtJS 4.1.1
0 3620
Simple class XmlParser to retrieve tree nodes from XML string.

Js Code

try {
    if (window.DOMParser) {
        xml = new DOMParser().parseFromString(text, "text/xml");
    } else {
        xml = new ActiveXObject("Microsoft.XMLDOM");
        xml.async = false;
        xml.loadXML(text);
    }
    valid = true;
} catch (e) {
    Ext.Msg.alert('Error', e.message);
}
            

ExtJS 4: TreePanel From Uploaded Xml File

Posted By Vitaliy | February 24, 2013 | ExtJS 4.1.1
0 3298
​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);
        }
    });
}