Not getting data from AW.XML.Table
Based on a V2.0 thread in the forum, I've used the following example code for the test:
var dataTable = new AW.XML.Table; dataTable.setURL("myfilename"); dataTable.setColumns(["Device", "Status", "Timestamp", "Appr Rate", "Balance"]); dataTable.request(); var gridObj = new AW.UI.Grid; gridObj.setColumnCount(5); gridObj.setHeaderText(["Device", "Status", "Timestamp", "Appr Rate", "Balance"]); gridObj.setCellModel(dataTable); document.write(gridObj);
If I look at the table right after the dataTable.request();, it contains zero rows. If I wait half a second and look at the table after it's had time to fetch the data, I see 15 rows. If I add gridObj.refresh(); at this point, which I expected to be the last required step, I still see nothing in the grid.
The XML data, from the V1.xx code, looks like this:
<?xml version="1.0"?> <ArrayOfDevices xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://tempuri.org/"> <device> <id>Y5562201</id> <status>Up</status> <timestamp>01/01/2006 12:13:15</timestamp> <approval>57%</approval> <balance>123456</balance> </device> ... </ArrayOfDevices>
Error: uncaught exception: [Exception... "The expression is not a legal expression." code: "51" nsresult: "0x805b0033 (NS_ERROR_DOM_INVALID_EXPRESSION_ERR)" location: "http://localhost:8080/pages/ActiveWidgets/source/lib/xml/table.js Line: 212"]
Thanks in advance for any help anyone can offer.
Could this be related to the grid.refresh() bug you mentioned this afternoon?
I think the problem might be related to xml namespace declaration - xmlns="http://tempuri.org/"
There is an example file in /examples/old/xml-arrayofrecords.htm with a very similar data format - /examples/data/companies-array.xml
If you have a namespace declared in XML file - you should also define it in the table object and use in XPath -
// define namespace for selecting column data table.setNamespace("co", "http://tempuri.org/"); // set column XPath table.setColumns(["co:ticker", "co:name", "co:marketcap", "co:sales", "co:employees", "co:timestamp"]);
Thanks for the info and the quick reply.
Okay, the dumb thing I did was to not realize that the columns definition for a table differed from the columns definition of a grid (the the table can now read XML tags--cool), so I was using the column heading values for the table column definitions.
I fixed that, and I now get "undefined" in all the cells, as expected when the table hasn't had time to load the data yet. No error messages showning up now. So far, so good.
However, after the table has loaded and I refresh the grid, I still get "undefined" in all the cells, so this appears to be a grid refresh problem, which may be the one you've mentioned for other queries on V2.0 grids.
Anything I can test to see if this is in fact the problem?
Any idea on what the problem is, or how long until we get a workaround?
When I did see it again, and removed, it, everything started working just fine. I also found the setAsync(false) option, which makes initial debugging much easier, even if it's not what you want in the long run.
This topic is archived.
Back to support forum
Version 2Looking for AW 2.6 ?
The old site is here.