Loading Table from XML in JavaScript variable
For several reasons I have to do SOAP using some non-AW JavaScript. This works fine, I end up with a J/S object that is a collection of XML nodes which I can either use myVar.xml or myVar.text to get the values I expected. However, I cannot seem to get that in an AW.XML.Table or view correctly in my AW grid.
I have an XMLHTTP request that returns my response, which gets
further parsed down the the correct part of the XML with:
var nd = responseNode.getElementsByTagName("Checks")[0];
I thought it would be as simple as setting the table's XML like:
var table = new AW.XML.Table;
table.setXML(nd);
var obj = new AW.UI.Grid;
obj.setId("myGrid");
obj.setColumnCount(3);
var columns = ["Check No", "Amount", "Date"];
obj.setHeaderText(columns);
var str = new AW.Formats.String;
var num = new AW.Formats.Number;
var money = new AW.Formats.Number;
money.setTextFormat("$ #,###,###.##");
var dte = new AW.Formats.Date;
dte.setDataFormat("ISO8601");
dte.setTextFormat("mm/dd/yy");
obj.setCellFormat([str, money, dte]);
obj.setCellModel(table);
document.write(obj);
But this doesn't work at all.
My XML looks like:
<Checks> <CheckRow><CheckNo>1</CheckNo><Amount>123.45</Amount><CheckDate>2000-01-01</CheckDate></CheckRow>
<CheckRow><CheckNo>2</CheckNo><Amount>99.10</Amount><CheckDate>2000-01-01</CheckDate></CheckRow>
<CheckRow><CheckNo>3</CheckNo><Amount>5.00</Amount><CheckDate>2000-01-01</CheckDate></CheckRow>
</Checks>
I've tried various iterations of the setXML:
table.setXML(nd.xml);
table.setXML(nd.text);
All of which do not work, and I believe the nd.text part even gives me an
error saying that's the wrong object type passed.
I've also tried to display the nd.xml before I create the table & grid,
and it's perfect. I can't even do var myVar = table.getXML(); after
the setXML - that returns nothing.
To complicate this - if I store my XML to a file, the exact way
it's stored in nd.xml, I can then setURL("myXML.xml") and request() -
and the grid displays perfectly!
It's like setXML() is just broken. Or there's some other step
the request() does behind the scenes that's missing for
the table to be initialized and useable for the
setCellModel(). (but I'm thinking it's the table and not
just the grid since I can't seem to get the getXML()
to return the right values either.
Any suggestions?
I have an XMLHTTP request that returns my response, which gets
further parsed down the the correct part of the XML with:
var nd = responseNode.getElementsByTagName("Checks")[0];
I thought it would be as simple as setting the table's XML like:
var table = new AW.XML.Table;
table.setXML(nd);
var obj = new AW.UI.Grid;
obj.setId("myGrid");
obj.setColumnCount(3);
var columns = ["Check No", "Amount", "Date"];
obj.setHeaderText(columns);
var str = new AW.Formats.String;
var num = new AW.Formats.Number;
var money = new AW.Formats.Number;
money.setTextFormat("$ #,###,###.##");
var dte = new AW.Formats.Date;
dte.setDataFormat("ISO8601");
dte.setTextFormat("mm/dd/yy");
obj.setCellFormat([str, money, dte]);
obj.setCellModel(table);
document.write(obj);
But this doesn't work at all.
My XML looks like:
<Checks> <CheckRow><CheckNo>1</CheckNo><Amount>123.45</Amount><CheckDate>2000-01-01</CheckDate></CheckRow>
<CheckRow><CheckNo>2</CheckNo><Amount>99.10</Amount><CheckDate>2000-01-01</CheckDate></CheckRow>
<CheckRow><CheckNo>3</CheckNo><Amount>5.00</Amount><CheckDate>2000-01-01</CheckDate></CheckRow>
</Checks>
I've tried various iterations of the setXML:
table.setXML(nd.xml);
table.setXML(nd.text);
All of which do not work, and I believe the nd.text part even gives me an
error saying that's the wrong object type passed.
I've also tried to display the nd.xml before I create the table & grid,
and it's perfect. I can't even do var myVar = table.getXML(); after
the setXML - that returns nothing.
To complicate this - if I store my XML to a file, the exact way
it's stored in nd.xml, I can then setURL("myXML.xml") and request() -
and the grid displays perfectly!
It's like setXML() is just broken. Or there's some other step
the request() does behind the scenes that's missing for
the table to be initialized and useable for the
setCellModel(). (but I'm thinking it's the table and not
just the grid since I can't seem to get the getXML()
to return the right values either.
Any suggestions?
Geoff
March 6,