Hybrid View

    Thank you for reporting this bug. We will make it our priority to review this report.
  1. #1
    Sencha User
    Join Date
    Nov 2012
    Posts
    20
    Vote Rating
    0
    malfurion559 is on a distinguished road

      0  

    Default Unanswered: Open File Problem

    Unanswered: Open File Problem


    Hello Guys,

    I'm trying to Open a File and load this file in a Store and Show this in a Tree.

    How can i get it work.

    I have Created a little Example to Show you how i'm trying it.

    app.js

    Code:
    Ext.application({    name: 'Demo',
        appFolder: 'app',
    
    
        stores: [
            'Components'
        ],
        models: [
            'Section'
        ],
        
        launch: function() {
            var xmlpath;
        
            if (typeof Ion != 'undefined'){
                var result = Ion.io.browseFiles({
                    path: Ion.io.userHomePath,
                    type: 'open',
                    filters: [{
                        name: 'XML Files .xml',
                        pattern: '*.xml'
                    }]
                });
                
                if (result.success) {
                    this.getStore('Components').proxy.url = result.value;
                }
            }
            else {
                this.getStore('Components').proxy.url = 'data/test.xml';
            }
            
            Ext.create('Ext.container.Viewport', {
                layout: 'fit',
                items: [
                    {
                        xtype: 'treepanel',
                        title: 'Users',
                        store: 'Components',
                        useArrows: true,
                        displayField: 'short_text',
                        html: 'List of users will go here'
                    }
                ]
            });
    
    
            this.getStore('Components').load();
        }
    });
    conponents.js:

    Code:
    Ext.define('Demo.store.Components', {    extend: 'Ext.data.TreeStore',
        requires: [
            'Demo.model.Section'
        ],
        model: 'Demo.model.Section',
        autoLoad: false,
    
    
        proxy: {
            type: 'ajax',
            url: '',
            reader: {
                type: 'xml',
                root: 'Sections',
                record: '>Section'
            }
        }
    });
    section.js:

    Code:
    Ext.define('Demo.model.Section', {    extend: 'Ext.data.Model',
    
    
        idProperty: 'id',
    
    
        fields: [
            {
                name: 'id',
                mapping: 'ComponentID',
                type: 'string'
            },
            {
                name: 'parent_Id',
                mapping: 'ParentID',
                type: 'string'
            },
            {
                name: 'short_text',
                mapping: 'Text/ShortText',
                type: 'string'
            }
        ]
    });
    screenshots:

    browser:

    2013-04-26 12_07_36-Demo.png

    desktop packager:

    2013-01-01 12_09_38-Demo [built using a trial of Sencha Desktop Packager, expiring on 1_15_2013].png

    kind regards

    malfurion

  2. #2
    Ext JS Premium Member
    Join Date
    May 2011
    Posts
    52
    Vote Rating
    1
    h.koch is on a distinguished road

      0  

    Default


    I had a similar situation (with fix JSON data). I had to define the data in the store itself, and not relying on its online ressource. Example:
    Code:
    Ext.define('OS4X_admin.store.certificateTypeStore', {
        extend: 'Ext.data.Store',
    
        constructor: function(cfg) {
            var me = this;
            cfg = cfg || {};
            me.callParent([Ext.apply({
                autoLoad: true,
                storeId: 'certificateTypeStore',
                data: [
                    {
                        idx: '1',
                        type: 'myself'
                    },
                    {
                        idx: '2',
                        type: 'partner'
                    }
                ],
                fields: [
                    {
                        name: 'idx'
                    },
                    {
                        name: 'type'
                    }
                ]
            }, cfg)]);
        }
    });

  3. #3
    Sencha User
    Join Date
    Nov 2012
    Posts
    20
    Vote Rating
    0
    malfurion559 is on a distinguished road

      0  

    Default


    hello,

    i do not understand what you mean because you have set the data of the store fixed but i can't set it fix because the xml file dosn't comes from me so i can't set the store data fixed

    i have also seen that if i will set the proxy url fixed that he has the same problem.

    Code:
    Ext.define('Demo.store.Components', {    extend: 'Ext.data.TreeStore',
        requires: [
            'Demo.model.Section'
        ],
        model: 'Demo.model.Section',
        autoLoad: false,
    
    
        proxy: {
            type: 'ajax',
            url: 'data/test.xml',
            reader: {
                type: 'xml',
                root: 'Sections',
                record: '>Section'
            }
        }
    });
    he loads the xml but doesn't show it.

    in browser:

    2013-05-07 15_01_21-Demo.png

    in desktop packager:

    2013-01-01 15_19_38-Demo [built using a trial of Sencha Desktop Packager, expiring on 1_15_2013].png

    kind regards
    malfurion

  4. #4
    Sencha User
    Join Date
    Jan 2012
    Posts
    22
    Vote Rating
    0
    Mark Dyer is on a distinguished road

      0  

    Default


    Hi malfurion559,

    I haven't actually tried this, but Ion.ui.browseFiles returns a path, not a url, so you might need to add 'file:///' to the beginning of the path when you set the store's proxy_url.

  5. #5
    Sencha User
    Join Date
    Nov 2012
    Posts
    20
    Vote Rating
    0
    malfurion559 is on a distinguished road

      0  

    Default


    Hello Mark,

    i have testet it but this dosn't work i think that the url is not the problem because the xml is loaded but the data aren't in the store.

  6. #6
    Sencha User
    Join Date
    Jan 2012
    Posts
    22
    Vote Rating
    0
    Mark Dyer is on a distinguished road

      0  

    Default


    Sorry to hear it didn't help. If the xml is being loaded, but not making it into the store, it sounds like this might be more of an ExtJS problem than a Desktop Packager problem. Have you posted anything over in the ExtJS specific forums?

  7. #7
    Sencha - Community Support Team hendricd's Avatar
    Join Date
    Aug 2007
    Location
    Long Island, NY USA
    Posts
    5,962
    Answers
    9
    Vote Rating
    10
    hendricd will become famous soon enough hendricd will become famous soon enough

      0  

    Default


    The thing to remember with loading from a file system - is the lack of a Content-type header. Without it, the XHR object will not parse and construct the required responseXML object. When reading from the file system, such a payload must be processed manually using:

    Code:
    var domParser = new DOMParser(),
          xdoc = domParser.parseFromString(response.responseText , 'application\/xml');
    "be dom-ready..."
    Doug Hendricks

    Maintaining ux: ManagedIFrame, MIF2 (FAQ, Wiki), ux.Media/Flash, AudioEvents, ux.Chart[Fusion,OFC,amChart], ext-basex.js/$JIT, Documentation Site.


    Got Sencha licensing questions? Find out more here.


film izle

hd film izle

film sitesi

takipci kazanma sitesi

takipci kazanma sitesi

güzel olan herşey

takipci alma sitesi

komik eğlenceli videolar