PDA

View Full Version : Help with Extjs XML reader



babaqga123
15 Apr 2010, 2:45 AM
Hello, fellow forum members. I am new to Extjs and I am having the following problem:
My Xml reader just doesn't read the xml file that i specify, or the grid doesn't display it. I have read a couple of forum entries before posting this, and some of them were pretty close to my problem. HOWEVER, I do get something differently: I get this message by my javascript debugger (firebug):


chrome://firebug/content/blank.gifExt.DomHelper=function(){var s=null,j=...(){return("DragDrop "+this.id)}}})(); Here is my code of both the xml file and the html:

baba.xml:



<?xml version="1.0" encoding="UTF-8"?>
<bookstore>

<book>
<title>Sexual Healing</title>
<author>Gonzo</author>
<year>2005</year>
<price>29.99</price>
</book>
<book>
<title>Ninjas</title>
<author>Mitsubishi</author>
<year>2003</year>
<price>39.95</price>
</book>
</bookstore>
baba.html:


<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<link rel="stylesheet " href="javascript libs/ext-3.2.0/resources/css/ext-all.css">
<script type="text/javascript" src="javascript libs/ext-3.2.0/adapter/ext/ext-base.js"></script>
<script type="text/javascript" src="javascript libs/ext-3.2.0/ext-all.js"></script>
<html>
<head>
<meta http-equiv="Content-Type" content="text/xml" charset=UTF-8">
<script>
Ext.onReady(function()
{ Ext.BLANK_IMAGE_URL = 'javascript libs/ext-3.2.0/resources/images/default/s.gif';

var book = new Ext.data.Record.create([{name:'title'},{name:'author'},{name: 'year'}]);
var ds = new Ext.data.Store
({
proxy: new Ext.data.HttpProxy({url: 'baba.xml'}),
reader: new Ext.data.XmlReader
({
record: 'book',
id: 'title',
totalRecords: 2
}, book)

});


var cm = new Ext.grid.ColumnModel
([
{header: "Title", width: 120, dataIndex: 'title'},
{header: "Author", width: 180, dataIndex: 'author'},
{header: "Year", width: 115, dataIndex: 'year'},
]);
cm.defaultSortable = true;
var grid = new Ext.grid.GridPanel('example-grid',
{
ds: ds,
cm: cm,
sm: new Ext.grid.RowSelectionModel({singleSelect:true}),
width: 600,
height: 300,
title: 'Framed with Row Selection and Horizontal Scrolling'

});
grid.render('baba');
ds.load({params:{start: 0, limit: 2}});
});
</script>

<title>
TestGrid
</title>
</head>
<body>
<div id="baba"></div>
</body>
</html>