PDA

View Full Version : Ext.XTemplate Problem with Explorer



ktemur
5 Dec 2010, 7:56 AM
Hi,

i am creating a datasource from xml file and want to show it on page in a div. For showing in html div i am using following code :


dataStore.load();

dataStore.on('load', function (store, records, options) {
var tpl = new Ext.XTemplate(
'<tpl for=".">',
'<li><a href="#">{values.data.MenuGroup}</a>',
'<ul>',
'<tpl for="values.data.Submenus">',
'<li><a href="{values.data.Url}">{values.data.Name}</a></li>',
'</tpl>',
'</ul>',
'</li>',
'</tpl>'
);
tpl.append(Ext.get("menuPanelDiv2"), dataStore.getRange());
});


This code works fine in firefox and chrome but doesn't work with explorer.
Iam using explorer 7. I couldn't understand the reason, could somebody help me about this issue?

Condor
5 Dec 2010, 8:06 AM
Is menuPanelDiv2 and <ul>? Otherwise you are rendering <li>s without a surrounding <ul>.

ktemur
5 Dec 2010, 8:24 AM
Hi Condor,

Sorry for mistake, menuPanelDiv2 was a <ul> before and it was not working too, then i changed it to a "<div>".

?n fact the problem is even if i write following code, it is still not working on explorer, other browsers are fine:


dataStore.on('load', function (store, records, options) {
var tpl = new Ext.XTemplate(
'<tpl for=".">',
'This is a TEST',
'</tpl>'
);
tpl.append(Ext.get("menuPanelDiv2"), dataStore.getRange());
});

ktemur
5 Dec 2010, 8:25 AM
is there any other solution to print my data source in to html?

Condor
5 Dec 2010, 8:57 AM
Is the data returned by the server valid JSON (no trailing commas)?

Is the data returned by the server valid XML (Content-type: text/xml or application/xml)?

ktemur
5 Dec 2010, 9:44 AM
Data is coming from a valid xml file. Full code is:


var submenuReader = new Ext.data.XmlReader({
record: 'Menu',
id: '@name',
fields: [
{name: 'Name', mapping: '@name'},
{name: 'Url', mapping: '@url'},
{name: 'Menu', mapping: '/'}
]
});

var dataStore = new Ext.data.Store({
proxy: new Ext.data.HttpProxy({
url: 'menu.xml'
}),
reader: new Ext.data.XmlReader({
record: 'Item',
id: 'MenuGroup',
fields: [
'MenuGroup',
{name: 'Submenus', convert: function(v, n){
return submenuReader.readRecords(n).records;
}}
]
})
});

dataStore.load();

dataStore.on('load', function (store, records, options) {
var tpl = new Ext.XTemplate(
'<tpl for=".">',
'<li><a href="#">{values.data.MenuGroup}</a>',
'<ul>',
'<tpl for="values.data.Submenus">',
'<li><a href="{values.data.Url}">{values.data.Name}</a></li>',
'</tpl>',
'</ul>',
'</li>',
'</tpl>'
);
tpl.append(Ext.get("menuPanelDiv2"), dataStore.getRange());
});

mankz
5 Dec 2010, 10:15 AM
Your template is not valid, as Condor pointed out - the top li node has no ul parent.

ktemur
5 Dec 2010, 12:00 PM
Hi,

i have set context-type as following but result didnt change, i still cannot see on explorer...


var dataStore = new Ext.data.Store({
proxy: new Ext.data.HttpProxy({
url: 'menu.xml',
method:'get',
headers: {"Content-Type": "text/xml; charset=utf-8"}
}),

i tried also with "application/xml"

Animal
5 Dec 2010, 12:03 PM
That's the request isn't it?

The server must tell some browsers what kind of data it is returning. Some attempt to parse as XML anyway, but some require that header.

ktemur
5 Dec 2010, 12:22 PM
The server must tell some browsers what kind of data it is returning. Some attempt to parse as XML anyway, but some require that header.

What can we do about this issue, do you have any idea?

Animal
5 Dec 2010, 12:53 PM
Set the header.

How you do that depends on your server technology.

Usually, when serving a hardcoded file, HTTP servers examine the file extension and make a best guess. Apache will do that. I'm surprised your server does not.

Or maybe it does, and there's another problem. What does the response packet look like?