Ask a Question related to Macromedia Flex General Discussion, Design and Development.
-
kohinoor75 #1
DataGrid + http does not work
I try to fill a DataGrid from live XML data over http, but the grid
desperately stays empty.
The code is :
<mx:HTTPService id="catalogContents" contentType="application/xml"
method="GET" protocol="http" resultFormat="xml"
url="http://localhost:8080/protocore/getCatalogContents"
fault='alert(event.fault.faultstring,"",mx.control s.Alert.OK)'
result='alert("Catalog OK","",mx.controls.Alert.OK)'>
<mx:DataGrid id="catalogGrid" height="100%" width="100%"
dataProvider="{catalogContents.result.element}">
Returned XML is like :
<?xml version="1.0" encoding="utf-8"?>
<elements>
<element Key="Key" Name="Name" Dir="Dir" lang="lang" nloc="nloc"
npar="npar" UNKNOWN1="UNKNOWN1" UNKNOWN2="UNKNOWN2" Status="Status"
Anom="Anom" label="label0" />
<element Key="BAT000000" Name="COA034" Dir="A1/PRG" lang="Cobol"
nloc="944" npar="649" UNKNOWN1="58" UNKNOWN2="" Status="CORRECT"
Anom="OK" label="label1" />
<element ...>
</elements>
I know that the Server part is OK, as I am able to display raw XML
code in the following TextArea:
<mx:TextArea text="{catalogContents.result}"/>
I tried the same, with XML compiled statically, and it works :
<mx:Model id="catalogContentsModel"
ource="D:\\src\\Flex\\Phoenix-proto\\cataloContents.xml" />
<mx:DataGrid id="catalogGrid"
dataProvider="{catalogContentsModel.result.element }">
Help would be greatly needed, I tried many different combinations of
returned XML without success (like returning <mx:Array>/<mx:Object>
tags, specifying the object attributes as XML attributes or as XML
elements, nothing work)
Am I *really* an idiot as I seem to be the only one with this problem
?:disgust;[url]http://localhost:8080/protocore/getCatalogContents[/url]
kohinoor75 Guest
-
Http sessions work but Https does not?? (IE cacheing bug?)
I'm using PHP 4.32 + Apache and testing with IE under W2K. When I call pages using HTTP everything works fine, users can log in and out, the data... -
Chart with http data does not work
I try to create a chart with live http data. I cannot figure how to make the chart appear correctly. With the same code, if I bind statically the... -
HTTP Services for DataGrid
why is it that, when we send a web request for some data from a .jsp or .xml file, for a datagrid , we dont get the result displayed on the DataGrid... -
Added CheckBox to a DataGrid Doesn't work with DataGrid.Enabled=False
I have created a Template Column and Added to a Datagrid, which contains a checkBox. The column is not Binded to any column of the Dataset, but is... -
FORMS only work if you HTTP
FORMS only work if you upload using http, do not upload forms using ftp. It is a frontpage thing, you must have front page extensions on your web... -
twoei22 #2
Re: DataGrid + http does not work
Hi man,
i had the same problem and as I could not fond an Xpath way to do something
like this
<mx:DataGrid id="myDataGrid">
<mx:dataProvider>{catalogContents.result.element }</mx:dataProvider>
<mx:columns>
<mx:Array>
<mx:DataGridColumn columnName="element[@Key]" headerText="Key
Number"/>
<mx:DataGridColumn columnName="element[@Name]" headerText="The
Name"/>
</mx:Array>
</mx:columns>
</mx:DataGrid>
Accessing a specific attribute depending on it s name...
What i did is reformat my xml to something like this:
<elements>
<element>
<Key>BAT000000</Key>
<Name>COA034</Name>
<Dir>A1/PRG</Dir>
etc...
</element>
<element>
<Key>BAT11111</Key>
<Name>COA066</Name>
<Dir>A1/PRG</Dir>
etc...
</element>
</elements>
and then access it like this:
<mx:DataGrid id="myDataGrid">
<mx:dataProvider>{catalogContents.result.element }</mx:dataProvider>
<mx:columns>
<mx:Array>
<mx:DataGridColumn columnName="Key" headerText="Key Number"/>
<mx:DataGridColumn columnName="Name" headerText="The Name"/>
<mx:DataGridColumn columnName="Dir" headerText="Direction"/>
</mx:Array>
</mx:columns>
</mx:DataGrid>
It sux a bit but I think that schemantically speaking it s more correct to
have all these as children nodes rather than attributes.
Hope this helps./
Mani
twoei22 Guest
-
ntsiii #3
Re: DataGrid + http does not work
The basic problem is that XML is hierarchical, and the Datagrid is tabular(a 2
dimensional array). I had so much trouble in the beginning using XML with a
datagrid that I just wrote a function that reads the XML and builds a 2dArray,
and my troubles went away.
I tried to solve this withoug doing that, but duplicated the unexpected
behavior that a model populated statically works fine, but one populated using
binding (with the same XML) does not. here is the sample app that shows the
behavior.
Oh, I can get it to work sort of by using the childNodes property(remember,
dataGrid wants an array of items, and childNodes produces an array), but that
produces an extra blank line for the implicit textNode.
It would be nice to solve this once and for all.
Tracy
<?xml version="1.0" encoding="utf-8"?>
<mx:Application xmlns:mx="http://www.macromedia.com/2003/mxml"
initialize="initApp()">
<mx:Script><![CDATA[
private var gXMLDoc:XMLNode;
private var gaXMLData:Array;
private function initApp():Void
{
var sXML:String =
"<elements>" +
"<element Key='Key' Name='Name' Dir='Dir' lang='lang' nloc='nloc' " +
"Anom='Anom' label='label0' />" +
"<element Key='BAT000000' Name='COA034' Dir='A1/PRG' lang='Cobol' " +
"Anom='OK' label='label1' />" +
"<elements>"
gXMLDoc = mx.utils.XMLUtil.createXML(sXML);
gaXMLData = gXMLDoc.firstChild.childNodes
}//
]]></mx:Script>
<mx:Model id="modelXMLB">{gXMLDoc}</mx:Model>
<mx:Model id="modelXML">
<elements>
<element Key="Key" Name="Name" Dir="Dir" lang="lang" nloc="nloc"
Anom="Anom" label="label0" />
<element Key="BAT000000" Name="COA034" Dir="A1/PRG" lang="Cobol"
Anom="OK" label="label1" />
</elements>
</mx:Model>
<mx:DataGrid id="dgSource" dataProvider="{gaXMLData}" rowCount="3">
<mx:columns>
<mx:Array>
<mx:DataGridColumn headerText="Key" columnName="Key" />
<mx:DataGridColumn headerText="Name" columnName="Name" />
<mx:DataGridColumn headerText="Dir" columnName="Dir" />
</mx:Array>
</mx:columns>
</mx:DataGrid>
<mx:DataGrid id="dgSourceModelB" dataProvider="{modelXMLB.elements.element}"
rowCount="3">
<mx:columns>
<mx:Array>
<mx:DataGridColumn headerText="Key" columnName="Key" />
<mx:DataGridColumn headerText="Name" columnName="Name" />
<mx:DataGridColumn headerText="Dir" columnName="Dir" />
</mx:Array>
</mx:columns>
</mx:DataGrid>
<mx:DataGrid id="dgSourceModel" dataProvider="{modelXML.elements.element}"
rowCount="3">
<mx:columns>
<mx:Array>
<mx:DataGridColumn headerText="Key" columnName="Key" />
<mx:DataGridColumn headerText="Name" columnName="Name" />
<mx:DataGridColumn headerText="Dir" columnName="Dir" />
</mx:Array>
</mx:columns>
</mx:DataGrid>
<mx:Button label="Button1" click="alert(modelXMLB.toString())"/>
<mx:Button label="Button2" click="alert(modelXML.toString())"/>
</mx:Application>
ntsiii Guest



Reply With Quote

