PDA

View Full Version : xml reader- not able to trace my issue-help!



ajay
20 Aug 2007, 12:24 PM
Hi,

This is my first stabb at ext

Ext.onReady
(
function()
{
var RecordDef = Ext.data.Record.create([
{name: 'Author', mapping: 'Author'}, // "mapping" property not needed if it's the same as "name"
{name: 'Title', mapping: 'Title'},
{name: 'Manufacturer', mapping: 'Manufacturer'},
{name: 'ProductGroup', mapping: 'ProductGroup'} // This field will use "occupation" as the mapping.
]);
var myReader = new Ext.data.XmlReader({

record: "Item" // The repeated element which contains row information

}, RecordDef);


var dataStore = new Ext.data.Store({
proxy: new Ext.data.HttpProxy({url: '/wbas/secure/AssignmentDownload.do'}),
reader: myReader
});



dataStore.load();
var colModel = new Ext.grid.ColumnModel([
{header: "Appraisal #", width: 120, dataIndex: 'Author'},
{header: "Title", width: 180, dataIndex: 'Title'},
{header: "Manufacturer", width: 115, dataIndex: 'Manufacturer'},
{header: "Product Group", width: 100, dataIndex: 'ProductGroup'}
]);


var grid = new Ext.grid.Grid('grid-example', {ds: dataStore, cm: colModel});


grid.render();

Ext.MessageBox.show({msg: grid.getDataSource().getTotalCount() });


//grid.getSelectionModel().selectFirstRow();



}
);




This is my server side code which flushes out xml..

PrintWriter out = response.getWriter();
out.write("<?xml version=\"1.0\" encoding=\"UTF-8\"?>");


out.write("<Item> "+
" <Author>Sidney Sheldon</Author> " +
" <Title>Are You Afraid of the Dark?</Title> " +
" <Manufacturer>Warner Books</Manufacturer> " +
" <ProductGroup>Book</ProductGroup> " +
" </Item>");

response.setHeader("Cache-Control", "no-cache");
response.setContentType("text/xml");
out.flush();

I am able to see the xml returning from the server via firebug but the xml reader does not seem to be parsing becuase I see the table structure displayed but no records ( only one in my case) gets displayed.

Any help appreciated.8-|

Animal
21 Aug 2007, 2:14 AM
Looks OK. I think you just need to call load() last.

ajay
21 Aug 2007, 3:59 AM
Thanks for your response.

Tried the load() last. Still no avail.


Ext.onReady(function() {

var dataStore = new Ext.data.Store({
proxy: new Ext.data.HttpProxy({url: '/wbas/secure/AssignmentDownload.do'}),
reader: new Ext.data.XmlReader({
record: 'Item'

}, [
'Author', 'Title', 'Manufacturer', 'ProductGroup'
])
});

var colModel = new Ext.grid.ColumnModel([
{header: "Author", width: 120, dataIndex: 'Author'},
{header: "Title", width: 180, dataIndex: 'Title'},
{header: "Manufacturer", width: 115, dataIndex: 'Manufacturer'},
{header: "Product Group", width: 100, dataIndex: 'ProductGroup'}
]);



var grid = new Ext.grid.Grid('mygrid', {
ds: dataStore,
cm: colModel
});
grid.render();

dataStore.load();


});


Server side code..

import javax.servlet.http.*;

public class AssignmentDownloadAction extends Action {

public ActionForward execute(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) throws Exception {
ActionErrors errors = new ActionErrors();
ActionMessages msgs = new ActionMessages();

// return value

PrintWriter out = response.getWriter();
out.write("<?xml?>");


out.write("<dataset> <Item> "+
" <Author>Sidney Sheldon</Author> " +
" <Title>Are You Afraid of the Dark?</Title> " +
" <Manufacturer>Warner Books</Manufacturer> " +
" <ProductGroup>Book</ProductGroup> " +
" </Item> </dataset>");

response.setHeader("Cache-Control", "no-cache");
response.setContentType("text/xml");
out.flush();
return null;

}
}




Also another note, is it possible to get a ext 2.0 for evaluation. We are very interested but we need to prove the concept to management to get buy in.

Thanks.

Animal
21 Aug 2007, 4:37 AM
The only thing I can think of is that it didn't parse your XML response correctly.

What does the response look like in Firebug's "Net" tab?

What does http://extjs.com/deploy/ext/docs/output/Ext.data.XmlReader.html#xmlData look like in Firebug?

ajay
21 Aug 2007, 4:55 AM
Current JS file


Ext.onReady(function() {

var dataStore = new Ext.data.Store({
proxy: new Ext.data.HttpProxy({url: '/wbas/secure/AssignmentDownload.do'}),
reader: new Ext.data.XmlReader({
record: 'Item'

}, [
'Author', 'Title', 'Manufacturer', 'ProductGroup'
])
});

var colModel = new Ext.grid.ColumnModel([
{header: "Author", width: 120, dataIndex: 'Author'},
{header: "Title", width: 180, dataIndex: 'Title'},
{header: "Manufacturer", width: 115, dataIndex: 'Manufacturer'},
{header: "Product Group", width: 100, dataIndex: 'ProductGroup'}
]);



var grid = new Ext.grid.Grid('mygrid', {
ds: dataStore,
cm: colModel
});
grid.render();


dataStore.load();

Ext.Msg.alert({msg: dataStore.reader.xmlData});
});




Current Server side




import java.io.PrintWriter;
import java.util.*;

import org.apache.struts.action.*;




import javax.servlet.http.*;

public class AssignmentDownloadAction extends Action {

public ActionForward execute(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) throws Exception {
ActionErrors errors = new ActionErrors();
ActionMessages msgs = new ActionMessages();

// return value

PrintWriter out = response.getWriter();
out.write("<?xml?>");


out.write("<dataset> <Item> "+
" <Author>RC Sproull</Author> " +
" <Title>Are You Afraid of the Dark?</Title> " +
" <Manufacturer>Warner Books</Manufacturer> " +
" <ProductGroup>Book</ProductGroup> </Item> " +
" <Item> <Author>Monergism </Author> " +
" <Title>Commentary</Title> " +
" <Manufacturer>Warner Books</Manufacturer> " +
" <ProductGroup>Book</ProductGroup> " +

" </Item> </dataset>");

response.setHeader("Cache-Control", "no-cache");
response.setContentType("text/xml");
out.flush();
return null;

}
}

Animal
21 Aug 2007, 5:08 AM
Yes, but is it successfully parsing that XML?

You need to stop in Firebug and examine http://extjs.com/deploy/ext/docs/output/Ext.data.XmlReader.html#xmlData

ajay
21 Aug 2007, 5:21 AM
I expanded all the fields under "reader" which is the instance of XMLReader in Firebug but could not find the xmlData field that you pointed me to.

My guess is that it is not parsing the xml file.


However as I pointed out earlier the XML is returning from the server side as seen in the net tab of firebug.

Would you know under what other subfield xmlData could be hidden in?

Thanks.

hendricd
21 Aug 2007, 5:39 AM
try:




grid.render();

Ext.Ajax.on( {'requestexception',function(){console.log(['requestexception',arguments])}
,{'requestcomplete',function(){console.log(['requestcomplete',arguments])}
});

dataStore.load();



Then, start snooping at the response object's responseXML property and see if you have any 'parsererror' nodes in the XML doc. Are the XML result well-formed ?

Animal
21 Aug 2007, 5:45 AM
If you examined that after the load, then it's definitely not parsing it.

Copy the XML text from the Firebug response tab and paste it into an XML editor to check it's OK.

But it could be to do with your content type.

Try "application/xml"

Something in here about "text/xml" and unspecified character encoding...

http://www.rfc-editor.org/rfc/rfc3023.txt

ajay
21 Aug 2007, 5:45 AM
Could go any further..see pic

Thanks.

ajay
21 Aug 2007, 5:50 AM
Also tried pulling out xml reading definition out..no use.


Ext.onReady(function() {


var myReader = new Ext.data.XmlReader({
record: 'Item'

}, [
'Author', 'Title', 'Manufacturer', 'ProductGroup'
]);


var dataStore = new Ext.data.Store({
proxy: new Ext.data.HttpProxy({url: '/wbas/secure/AssignmentDownload.do'}),
reader: myReader });

var colModel = new Ext.grid.ColumnModel([
{header: "Author", width: 120, dataIndex: 'Author'},
{header: "Title", width: 180, dataIndex: 'Title'},
{header: "Manufacturer", width: 115, dataIndex: 'Manufacturer'},
{header: "Product Group", width: 100, dataIndex: 'ProductGroup'}
]);



var grid = new Ext.grid.Grid('mygrid', {
ds: dataStore,
cm: colModel
});
grid.render();




dataStore.load();


Ext.Msg.alert({msg: myReader.xmlData});
});



Current serverside code


import javax.servlet.http.*;

public class AssignmentDownloadAction extends Action {

public ActionForward execute(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) throws Exception {
ActionErrors errors = new ActionErrors();
ActionMessages msgs = new ActionMessages();

// return value

PrintWriter out = response.getWriter();
out.write("<?xml?>");


out.write("<dataset> <Item> "+
" <Author>RC Sproull</Author> " +
" <Title>Are You Afraid of the Dark?</Title> " +
" <Manufacturer>Warner Books</Manufacturer> " +
" <ProductGroup>Book</ProductGroup> </Item> " +
" <Item> <Author>Monergism </Author> " +
" <Title>Commentary</Title> " +
" <Manufacturer>Warner Books</Manufacturer> " +
" <ProductGroup>Book</ProductGroup> " +

" </Item> </dataset>");

response.setHeader("Cache-Control", "no-cache");
response.setContentType("application/xml");
out.flush();
return null;

}
}

hendricd
21 Aug 2007, 5:57 AM
grid.render();

Ext.Ajax.on( {'requestexception':function(){console.log(['requestexception',arguments])}
,{'requestcomplete':function(){console.log(['requestcomplete',arguments])}
});

dataStore.load();

carol.extjs
21 Aug 2007, 6:11 AM
I tried your javascript code with the sample xml file sheldon.xml[1] and it displayed the rows of data.

[1] sheldon.xml from the examples and demos under grid "Ajax XML data" http://extjs.com/deploy/ext/examples/grid/xml-grid.html

hendricd
21 Aug 2007, 6:15 AM
You might also want to try setting headers and such:


response.setHeader("Cache-Control", "no-cache");
response.setContentType("application/xml; charset=UTF-8");
response.charset = " ?? " etc......
...


... before you write any of the XML out.

Animal
21 Aug 2007, 6:22 AM
Hmmm. Yes. From the Javadocs of setContentType:



This method has no effect if called after the response has been committed. It does not set the response's character encoding if it is called after getWriter has been called or after the response has been committed.

ajay
21 Aug 2007, 6:24 AM
Tried with no success


response.setContentType("application/xml; charset=UTF-8");


Tried but with same property Id error

Ext.Ajax.on( {'requestexception':function(){console.log(['requestexception',arguments])} ,{'requestcomplete':function(){console.log(['requestcomplete',arguments])} });





I am able to use a memoryProxy and read from a table and get them listed but only the xml reader does not work

ohhowihateie
21 Aug 2007, 6:24 AM
There are several posts in this forum about property names not working properly when enclosed in quotes. I am no EXT expert, but you may try taking the quotes off your property names. For example:



Ext.Ajax.on( { requestexception : function() ...

That is what I would try if I were you.

hendricd
21 Aug 2007, 6:30 AM
@ohhowihateie - It's not the quotes ;)

Try this one:


Ext.Ajax.on( {'requestexception':function(){console.log(['requestexception',arguments])}
,'requestcomplete':function(){console.log(['requestcomplete',arguments])}
});

Just a copy/paste victim.

@ajay -


Tried with no success
* response.setContentType("application/xml; charset=UTF-8");

The point I was trying to make, is there is a point to be made ;) You need to work out your server-side encoding/header placement. Javadocs are great tools. To eliminate client side issues first, why not serve up that XML doc 'staticly' first and get the basic working ?

ohhowihateie
21 Aug 2007, 6:37 AM
Didn't see the syntax there.

hcervantes
21 Aug 2007, 6:37 AM
Ajay,
I am experiencing the exact same issue you are. I believe that the XML reader reads the data after the grid is rendered. I took the XML Grid example and ran some tests. Right after the ds.load call, I have an alert to show the number of records. If I run it without debuging it in Fire bug, it shows no records. However, if I put a breakpoint on the alert statement, and wait two seconds, then continue runing the script, all the records load fine.
Is this some delay reaction on the XML reader?



Ext.onReady(function(){
10
11 // create the Data Store
12 var ds = new Ext.data.Store({
13 // load using HTTP
14 proxy: new Ext.data.HttpProxy({url: 'sheldon.xml'}),
15
16 // the return will be XML, so lets set up a reader
17 reader: new Ext.data.XmlReader({
18 // records will have an "Item" tag
19 record: 'Item',
20 id: 'ASIN',
21 totalRecords: '@total'
22 }, [
23 // set up the fields mapping into the xml doc
24 // The first needs mapping, the others are very basic
25 {name: 'Author', mapping: 'ItemAttributes > Author'},
26 'Title', 'Manufacturer', 'ProductGroup'
27 ])
28 });
29
30 var cm = new Ext.grid.ColumnModel([
31 {header: "Author", width: 120, dataIndex: 'Author'},
32 {header: "Title", width: 180, dataIndex: 'Title'},
33 {header: "Manufacturer", width: 115, dataIndex: 'Manufacturer'},
34 {header: "Product Group", width: 100, dataIndex: 'ProductGroup'}
35 ]);
36 cm.defaultSortable = true;
37
38 // create the grid
39 var grid = new Ext.grid.Grid('example-grid', {
40 ds: ds,
41 cm: cm
42 });
43 grid.render();
44
45 ds.load();
46 Ext.Msg.alert("test", ds.getTotalCount()); // add breakpoint here and it loads fine
47});

ajay
21 Aug 2007, 6:43 AM
1. I put the break point at the alert, waited for a few seconds still did not work.

2. Current serverside code . Note the Headers are being set before xml is set. Still not working


import javax.servlet.http.*;

public class AssignmentDownloadAction extends Action {

public ActionForward execute(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) throws Exception {
ActionErrors errors = new ActionErrors();
ActionMessages msgs = new ActionMessages();
PrintWriter out = response.getWriter();
// return value
response.setHeader("Cache-Control", "no-cache");
response.setContentType("application/xml");

out.write("<?xml?>");


out.write("<dataset> <Item> "+
" <Author>RC Sproull</Author> " +
" <Title>Are You Afraid of the Dark?</Title> " +
" <Manufacturer>Warner Books</Manufacturer> " +
" <ProductGroup>Book</ProductGroup> </Item> " +
" <Item> <Author>Monergism </Author> " +
" <Title>Commentary</Title> " +
" <Manufacturer>Warner Books</Manufacturer> " +
" <ProductGroup>Book</ProductGroup> " +

" </Item> </dataset>");


out.flush();
return null;

}
}

hendricd
21 Aug 2007, 6:45 AM
@hcervantes - There are no results yet because the Ajax call is aynchronous and has not yet completed (ie: the load() call returns immediately) by the time:

Ext.Msg.alert("test", ds.getTotalCount());

is executed (without a BP).

try something like:


ds.load({callback:function(){Ext.Msg.alert("test", ds.getTotalCount());}});


the callback is fired after the response is received/loaded.

or

ds.on('load',function(){Ext.Msg.alert("test", ds.getTotalCount());})

ajay
21 Aug 2007, 6:50 AM
please see attachement. No Errors returned

ajay
21 Aug 2007, 6:55 AM
Doug Hendricks,

That was a good suggestion..

dataStore.load({callback:function(){Ext.Msg.alert("test", dataStore.getTotalCount());}});


I did get the alert with this but still no rows in the table and

I do see XML returning correctly in Firebug response tab.

hendricd
21 Aug 2007, 6:57 AM
@ajay - may we also see the (response) Headers tab ?

Also, examine (Browse in the DOM) the second parameter of the requestcomplete callback. Drill down to the responseXML property. Is it null, undefined ? Does the firstChild property nodeName = parsererror ?

Keep drilling down till ya find it.

And try saving your document statically first and use that as your source until you figure out how to generate the XML Doc properly serverside.

hendricd
21 Aug 2007, 7:01 AM
I do see XML returning correctly in Firebug response tab.

You will undoubtedly get a responseText value (that's just the raw text).

The XMLReader uses the responseXML property of the response (a DOMDocument) to parse because it has nodes easily traversable.

But, if your XML is not-well-formed or improperly encoded, a useful XMLDocument may not be created properly(at all).

hendricd
21 Aug 2007, 7:04 AM
And please:

Do Something like this:

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

ajay
21 Aug 2007, 7:05 AM
please see attachment for headers

hendricd
21 Aug 2007, 7:11 AM
/**
* @class Ext.data.XmlReader
* @extends Ext.data.DataReader
* Data reader class to create an Array of {@link Ext.data.Record} objects from an XML document
* based on mappings in a provided Ext.data.Record constructor.<br><br>
* <p>
* <em>Note that in order for the browser to parse a returned XML document, the Content-Type
* header in the HTTP response must be set to "text/xml".</em>



Read the Source Notes !

ajay
21 Aug 2007, 7:13 AM
Thanks all.

Not sure what did it. But among the many things I moved around..


I suspect it was the suggestion by hendricd to set the xml encoding correctly..

Someone. please correct the tutorial on the site.

Thanks again all.

ajay
21 Aug 2007, 7:15 AM
Java Script


Ext.onReady(function() {


var myReader = new Ext.data.XmlReader({
record: 'Item'

}, [
'Author', 'Title', 'Manufacturer', 'ProductGroup'
]);


var dataStore = new Ext.data.Store({
proxy: new Ext.data.HttpProxy({url: '/wbas/secure/AssignmentDownload.do'}),
reader: myReader });

var colModel = new Ext.grid.ColumnModel([
{header: "Author", width: 120, dataIndex: 'Author'},
{header: "Title", width: 180, dataIndex: 'Title'},
{header: "Manufacturer", width: 115, dataIndex: 'Manufacturer'},
{header: "Product Group", width: 100, dataIndex: 'ProductGroup'}
]);



var grid = new Ext.grid.Grid('mygrid', {
ds: dataStore,
cm: colModel
});
grid.render();


//Ext.Ajax.on( {'requestexception':function(){console.log(['requestexception',arguments])}
//,'requestcomplete':function(){console.log(['requestcomplete',arguments])}
// });

dataStore.load({callback:function(){Ext.Msg.alert("test", dataStore.getTotalCount());}});



});



Java Server side class serving XML


import java.io.PrintWriter;
import java.util.*;

import org.apache.struts.action.*;




import javax.servlet.http.*;

public class AssignmentDownloadAction extends Action {

public ActionForward execute(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) throws Exception {
ActionErrors errors = new ActionErrors();
ActionMessages msgs = new ActionMessages();
PrintWriter out = response.getWriter();
// return value
response.setHeader("Cache-Control", "no-cache");
response.setContentType("application/xml");

out.write("<?xml version=\"1.0\" encoding=\"UTF-8\"?>");


out.write("<dataset> <Item> "+
" <Author>RC Sproull</Author> " +
" <Title>Are You Afraid of the Dark?</Title> " +
" <Manufacturer>Warner Books</Manufacturer> " +
" <ProductGroup>Book</ProductGroup> </Item> " +
" <Item> <Author>Monergism </Author> " +
" <Title>Commentary</Title> " +
" <Manufacturer>Warner Books</Manufacturer> " +
" <ProductGroup>Book</ProductGroup> " +

" </Item> </dataset>");


out.flush();
return null;

}
}

Thanks again everybody!

hcervantes
21 Aug 2007, 7:36 AM
@hcervantes - There are no results yet because the Ajax call is aynchronous and has not yet completed (ie: the load() call returns immediately) by the time:



Thanks, Doug, that makes sence. I tried it and it worked, but the grid is not rendering any rows. If I put a BP in the code the grid does render fine. Do you have any idea what I am doing wrong?
Thanks

hendricd
21 Aug 2007, 7:48 AM
ds.on({
'load',function(){Ext.Msg.alert("test", ds.getTotalCount());}
,'loadexception',function(){console.log(['loadexception',arguments]);}
});


You have to use all the event handlers available to debug this stuff (and for production use), guys.

Anything can happen.

hcervantes
21 Aug 2007, 7:59 AM
Thanks, I'll keep on, keeping-on!

hendricd
21 Aug 2007, 8:20 AM
@hcervantes - You are running this through a web-server (not local file system) right ?

If not, you won't get a working XML document unless you do this (http://extjs.com/forum/showthread.php?t=10672).

hcervantes
21 Aug 2007, 9:05 AM
Yes, I am. I'm using .Net. I tryed your suggestion and an error is occuring, but I cannot figure out why. I look at the objects and it seems that the XML is geing read fine. What should I look for in Firebug?

hendricd
21 Aug 2007, 9:13 AM
Can you display the XML result directly in your browser, any complaints about structure ?

If that looks good,



Ext.Ajax.on( {'requestexception':function(){console.log(['requestexception',arguments])}
,'requestcomplete':function(){console.log(['requestcomplete',arguments])}
});

ds.load();


then see what's inside the response.responseXML(arguments[1]) property, that's your XMLDocument. Is there a firstChild node, (for IE its XML, Gecko is likely your root node or 'parsererror' if its not well-formed) , etc...

you should see the text version in the response.responseText property.

also look at the response.getAllResponseHeaders, Good Content-type header: [application]text/xml ?

hcervantes
21 Aug 2007, 10:40 AM
I still cannot figure why the proxy is returning an error. Here is what the getAll ResponseHeaders looks like:
Server: ASP.NET Development Server/8.0.0.0
Date: Tue, 21 Aug 2007 18:27:02 GMT
X-AspNet-Version: 2.0.50727
Cache-Control: no-cache
Pragma: no-cache
Expires: -1
Content-Type: text/xml; charset=iso-8859-2
Content-Length: 1148
Connection: Close

Ther responseXML looks fine also. Here is the responseText:
<?xml version="1.0" encoding="UTF-8"?><rows><TotalCount>5</TotalCount><row><AccountID>1</AccountID><TransID>0</TransID><Date>8/6/2007 12:00:00 AM</Date><Type>410</Type><Description>Boys &amp; Girls Club</Description><Credit /><Debit>25.00</Debit><Balance>1000.00</Balance><Cleared>1</Cleared></row><row><AccountID>1</AccountID><TransID>2</TransID><Date>8/8/2007 12:00:00 AM</Date><Type>Deposit</Type><Description>Deposit from 5/3rd</Description><Credit>300.00</Credit><Debit /><Balance>1300.00</Balance><Cleared>1</Cleared></row><row><AccountID>1</AccountID><TransID>3</TransID><Date>8/8/2007 12:00:00 AM</Date><Type>Visa</Type><Description>Fantastic Sams</Description><Credit /><Debit>43.80</Debit><Balance>1256.20</Balance><Cleared>1</Cleared></row><row><AccountID>1</AccountID><TransID>4</TransID><Date>8/9/2007 12:00:00 AM</Date><Type>Visa</Type><Description>PetroMart</Description><Credit /><Debit>40.00</Debit><Balance>1216.20</Balance><Cleared>0</Cleared></row><row><AccountID>1</AccountID><TransID>5</TransID><Date>8/9/2007 12:00:00 AM</Date><Type /><Description /><Credit /><Debit /><Balance>0.00</Balance><Cleared>0</Cleared></row></rows>

Here is my JS Code:


/*
* Ext JS Library 1.1
* Copyright(c) 2006-2007, Ext JS, LLC.
* licensing@extjs.com
*
* http://www.extjs.com/license
*/

Ext.onReady(function(){
Ext.Ajax.defaultHeaders = {Connection:'close'};
var ColumnNames = Ext.data.Record.create([
{name: 'AccountID'},
{name: 'TransID'},
{name: 'Date'},
{name: 'Type'},
{name: 'Description'},
{name: 'Credit'},
{name: 'Debit,'},
{name: 'Balance'},
{name: 'Cleared'}
]);
// create the Data Store
var ds = new Ext.data.Store({
// load using HTTP
proxy: new Ext.data.HttpProxy({url: 'DataHandler.ashx'}),

// the return will be XML, so lets set up a reader
reader: new Ext.data.XmlReader({
// records will have an "Item" tag
record: 'row',
id: 'TransID',
totalRecords: 'TotalCount'
}, ColumnNames)
});

var colDef = [
{header: 'Date', width: 40, dataIndex: 'Date', type: 'date', filter: 'numeric'},
{header: 'Type', width: 50, dataIndex: 'Type', type: 'string', filter: 'string'},
{header: 'Description', width: 135, dataIndex: 'Description', type: 'string', filter: 'string'},
{header: 'Credit', width: 80, dataIndex: 'Credit', type: 'decimal', filter: 'numeric'},
{header: 'Debit', width: 80, dataIndex: 'Debit', type: 'decimal', filter: 'numeric'},
{header: 'Balance', width: 80, dataIndex: 'Balance', type: 'decimal', filter: 'numeric'},
{header: 'Cleared', width: 40, dataIndex: 'Cleared', type: 'decimal', filter: 'numeric'}
];
var cm = new Ext.grid.ColumnModel(colDef);
cm.defaultSortable = true;

// create the grid
var grid = new Ext.grid.Grid('example-grid', {
ds: ds,
cm: cm
});
grid.render();

ds.load({callback:function(){
}});
ds.on('load',function(){
Ext.Msg.alert("test", ds.getTotalCount())
});
ds.on('loadexception',function(){
console.log(['loadexception',arguments])});
});



I can also view the XML output fine in browser with no errors.
Sorry to bug, and thanks.

hcervantes
21 Aug 2007, 11:08 AM
Funny thing is, it is not even firing the onLoad event.
ds.on('load',function(){
Ext.Msg.alert("test", ds.getTotalCount())
});

hendricd
23 Aug 2007, 8:53 AM
Then, setup a

ds.on('loadexception',....) to see whats up

hcervantes
23 Aug 2007, 9:26 AM
I can't find what the exception was. I've dug into all the objects returned by the exception, but I can't find an error. I'll keep digging through it.

hendricd
23 Aug 2007, 11:21 AM
They both ('load' and 'loadexception') need to be set BEFORE the load call.

hcervantes
24 Aug 2007, 12:25 PM
I figured it out and I feel sooo dumb! It was a measly little typo in the XMLReader. For the column names, I had accidentally left a comma inside a quote. See the Debit column:


var ColumnNames = Ext.data.Record.create([
{name: 'AccountID'},
{name: 'TransID'},
{name: 'Date'},
{name: 'Type'},
{name: 'Description'},
{name: 'Credit'},
{name: 'Debit,'},
{name: 'Balance'},
{name: 'Cleared'}
]);


Sorry for taking up your valuable time, but it was well worth it for me because I learned a few tricks from you, Doug.
Thanks again!

hendricd
24 Aug 2007, 12:37 PM
Glad you figured it out.

Guess I'm not as good a code reader as you are a 'typist'. =P~