Thank you for reporting this bug. We will make it our priority to review this report.
-
Sencha User
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
-
Ext JS Premium Member
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)]);
}
});
-
Sencha User
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
-
Sencha User
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.
-
Sencha User
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.
-
Sencha User
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?
-
Sencha User
no i haven't posted it into the extjs forum because if i will use the same code in my browser (chrome 24) it works
-
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');