PDA

View Full Version : xml-grid sample only works in IE



pllee
10 Nov 2009, 2:05 PM
The example given from the ExtJS\ext-3.0.0\examples\ folder for xml-grid.html only works in IE. It doesn't work in FF or Chrome. I am new to ext JS and I have changed the xml and html headers to "text/xml" but nothing seems to work. Is there something I have to do in FF to enable it to read certain xml files? I am asking this because I have created a similar script that reads xml data and it also only works in IE. Thanks in advance.


<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<title>XML Grid Example</title>
<link rel="stylesheet" type="text/css" href="../../resources/css/ext-all.css" />

<!-- GC -->
<!-- LIBS -->
<script type="text/javascript" src="../../adapter/ext/ext-base.js"></script>
<!-- ENDLIBS -->

<script type="text/javascript" src="../../ext-all.js"></script>

<script type="text/javascript" src="xml-grid.js"></script>
<link rel="stylesheet" type="text/css" href="grid-examples.css" />

<!-- Common Styles for the examples -->
<link rel="stylesheet" type="text/css" href="../shared/examples.css" />
</head>
<body>
<script type="text/javascript" src="../shared/examples.js"></script><!-- EXAMPLES -->
<h1>XML Grid Example</h1>
<p>This example shows how to load a grid with XML data.</p>

<p>This grid also uses autoHeight and autoWidth to dynamically size to fit it's data and columns.</p>

<p>Note that the js is not minified so it is readable. See <a href="xml-grid.js">xml-grid.js</a>.</p>

<p>The data in the grid is loaded from <a href="sheldon.xml">sheldon.xml</a>, which is directly from an Amazon.com search.</p>

<!-- a place holder for the grid. requires the unique id to be passed in the javascript function, and width and height ! -->
<div id="example-grid"></div>

</body>
</html>



/*!
* Ext JS Library 3.0.0
* Copyright(c) 2006-2009 Ext JS, LLC
* licensing@extjs.com
* http://www.extjs.com/license
*/
Ext.onReady(function(){

// create the Data Store
var store = new Ext.data.Store({
// load using HTTP
url: 'http://www.extjs.com/deploy/dev/examples/grid/sheldon.xml',

// the return will be XML, so lets set up a reader
reader: new Ext.data.XmlReader({
// records will have an "Item" tag
record: 'Item',
id: 'ASIN',
totalRecords: '@total'
}, [
// set up the fields mapping into the xml doc
// The first needs mapping, the others are very basic
{name: 'Author', mapping: 'ItemAttributes > Author'},
'Title', 'Manufacturer', 'ProductGroup'
])
});

// create the grid
var grid = new Ext.grid.GridPanel({
store: store,
columns: [
{header: "Author", width: 120, dataIndex: 'Author', sortable: true},
{header: "Title", width: 180, dataIndex: 'Title', sortable: true},
{header: "Manufacturer", width: 115, dataIndex: 'Manufacturer', sortable: true},
{header: "Product Group", width: 100, dataIndex: 'ProductGroup', sortable: true}
],
renderTo:'example-grid',
width:540,
height:200
});

store.load();
});

pllee
12 Nov 2009, 11:52 AM
Bump! Does anyone know how to fix the example from extjs.com or does it work fine for them? Any reply would be greatly appreciated.

aw1zard2
12 Nov 2009, 11:55 AM
In your original post make sure the
tags are correct your missing the [ on the [/code] tag.

aw1zard2
12 Nov 2009, 11:59 AM
Yeah I recreated it.

IE shouldn't be doing this the xml file should be in the same directory as your js.

Change this

url: 'http://www.extjs.com/deploy/dev/examples/grid/sheldon.xml',to this


url: 'sheldon.xml',And make sure the xml is in the same folder.
You can change which folder it somes from but just need to stay with the same domain.

carol.ext
12 Nov 2009, 12:00 PM
Fix your code tags so it is readable, you might get more looks.

Why are you not pointing to a sheldon.xml on your server? Oh, are you using a webserver or are you bringing it up as file://... ?

pllee
12 Nov 2009, 12:11 PM
Fix your code tags so it is readable, you might get more looks.

Why are you not pointing to a sheldon.xml on your server? Oh, are you using a webserver or are you bringing it up as file://... ?

Thanks for the responses. I am using the Web server that the example uses because xmlReader can not read local xml files.

aw1zard2
12 Nov 2009, 12:15 PM
Yes it can otherwise the example xml-grid you downloaded with Ext-JS 3 wouldn't work.

:)

Just make sure you goto http://yoururl/ext/examples/ and not file://url_to_html_file/

Like for my examples it's

http://localhost/ext-3.0.0/examples/grid/xml-grid.html

carol.ext
12 Nov 2009, 2:26 PM
Thanks for the responses. I am using the Web server that the example uses because xmlReader can not read local xml files.

Maybe there is a problem with the mime mapping for your web server. Can you load the xml file into your browser using local url (calling it directly)?

pllee
12 Nov 2009, 2:31 PM
Maybe there is a problem with the mime mapping for your web server. Can you load the xml file into your browser using local url (calling it directly)?

Yes it works fine, the main problem is that the sample only works on IE when activeX is run and it doesn't work on FF or chrome.

carol.ext
12 Nov 2009, 2:38 PM
Yes it works fine, the main problem is that the sample only works on IE when activeX is run and it doesn't work on FF or chrome.

Well, that REALLY sounds like you are not calling the html file through http://yourserver/ext/examples/grid/xml-grid.html

aw1zard2
12 Nov 2009, 2:39 PM
Read the note of HttpProxy in which Store uses.

Class:HttpProxy (http://www.extjs.com/forum/../deploy/dev/docs/source/HttpProxy.html#cls-Ext.data.HttpProxy)Extends:DataProxy (http://www.extjs.com/forum/../deploy/dev/docs/output/Ext.data.DataProxy.html)An implementation of Ext.data.DataProxy (http://www.extjs.com/forum/../deploy/dev/docs/output/Ext.data.DataProxy.html) that processes data requests within the same domain of the originating page.
Note: this class cannot be used to retrieve data from a domain other than the domain from which the running page was served. For cross-domain requests, use a ScriptTagProxy (http://www.extjs.com/forum/../deploy/dev/docs/output/Ext.data.ScriptTagProxy.html).
Be aware that to enable the browser to parse an XML document, the server must set the Content-Type header in the HTTP response to "text/xml".

http://www.extjs.com/deploy/dev/docs/?class=Ext.data.HttpProxy (http://www.extjs.com/forum/../deploy/dev/docs/?class=Ext.data.HttpProxy)

aw1zard2
12 Nov 2009, 2:45 PM
I did confirm that IE7 (didn't check 6 or 8) does allow this even though it shouldn't.
According to the API's firefox and chrome are acting correctly with using the httpproxy store url property.

VinylFox should this be considered a bug?

I saw you looking at the thread. :)

pllee
12 Nov 2009, 2:52 PM
Well, that REALLY sounds like you are not calling the html file through http://yourserver/ext/examples/grid/xml-grid.html

First of all thanks a lot for your help. I put the files on mylocalhost and now the example doesn't even run in IE.

In IE I get the error:
Line:8
Char 19445
Error: Access Denied
Code: 0
URL: localhost/...

aw1zard2
12 Nov 2009, 2:58 PM
First of all thanks a lot for your help. I put the files on mylocalhost and now the example doesn't even run in IE.

In IE I get the error:
Line:8
Char 19445
Error: Access Denied
Code: 0
URL: localhost/...

I copied and pasted your code to my localhost and confirmed IE7 does do this. It shows the data. But I got all 3 browsers working by having the xml file in the same folder and edited the url to only have the name of the xml file.
IE, Firefox, and Chrome all showed the correct results. If your having IE give access denied make sure your localhost is a trusted site in IE.

pllee
12 Nov 2009, 3:04 PM
I copied and pasted your code to my localhost and confirmed IE7 does do this. It shows the data. But I got all 3 browsers working by having the xml file in the same folder and edited the url to only have the name of the xml file.
IE, Firefox, and Chrome all showed the correct results. If your having IE give access denied make sure your localhost is a trusted site in IE.

Thanks for all the effort I really appreciate it. I'm going to put this issue on hold for now cause I will be trying to work on a workaround that has nothing to do with the example.

pllee
13 Nov 2009, 9:04 AM
Thanks for all the help:) I just figured out the problem it had something to do with the xml header not being set properly, once I fixed that the data was displayed correctly.