Peter_Chea
06-11-2003, 12:57 PM
I am trying to access a subview during the ondata event. Is possible?
<text name="price" multiline="true"/>
<method name="processData">
//debug.write(this.datapath.getNodeName());
this.price.setText(this.datapath.getXPath("price/text()") * 1.10);
</method>
<canvas debug="true">
<dataset name="hotelresult">
<item>
<name>BUENA VISTA SUITES</name>
<price>$20</price>
</item>
<item>
<name>QUALITY SUITES MAINGATE EAST</name>
<price>$20</price>
</item>
<item>
<name>HOLIDAY INN MAINGATE WEST</name>
<price>$20</price>
</item>
<item>
<name>RAMADA INN RESORT</name>
<price>$20</price>
</item>
<item>
<name>BDOUBLETREE RESORT VILLAS</name>
<price>$20</price>
</item>
<item>
<name>DAYS SUITES MAINGATE EAST</name>
<price>$20</price>
</item>
<item>
<name>HILTON WALT DISNEY WORLD</name>
<price>$20</price>
</item>
<item>
<name>HOWARD JOHNSON MAINGATE EAST</name>
<price>$20</price>
</item>
</dataset>
<class name="simplelayout2" extends="layout" >
<attribute name="axis" value="y" onset="this.setAxis( axis );"
type="string" />
<attribute name="spacing" value="0"
onset="this.spacing = spacing;
if( this.subviews.length ) this.update()"/>
<attribute name="altbgcolor" type="number"
onset="this.altbgcolor = altbgcolor;"/>
<method name="setAxis" args="a" >
this.axis = a;
this.sizeAxis = a == "x" ? "width" : "height"
</method>
<method name="addSubview" args="newsub">
this.updateDelegate.register( newsub, "on" + this.sizeAxis);
if ( ! this.locked && this.subviews.length ){
var s= this.subviews[ this.subviews.length-1 ];
var p = s.getAttribute( this.axis ) +
s.getAttribute( this.sizeAxis );
if ( this.subviews.length ){
p += this.spacing;
}
newsub.setAttribute( this.axis , p ) ;
}
super.addSubview( newsub );
</method>
<method name="update">
<![CDATA[
if ( this.locked ) return;
var l = this.subviews.length;
var c = 0;
for(var i=0; i < l; i++) {
var s = this.subviews[i];
if(i % 2)
{
//debug.write("altcolor:" + this.altbgcolor);
s.setAttribute("bgcolor", this.altbgcolor);
//s.setBGColor(this.altbgcolor);
}
else
{
//debug.write("normalcolor:" +this.bgcolor);
s.setAttribute("bgcolor", this.bgcolor);
}
s.setAttribute( this.axis , c );
//trace("setAttribute after= " + this.axis);
c += this.spacing + s.getAttribute( this.sizeAxis ) ;
}
]]>
</method>
</class>
<class name="copylayout" extends="layout" >
<attribute name="axis" value="y" onset="this.setAxis( axis )"
type="string" />
<attribute name="spacing" value="0"
onset="this.spacing = spacing;
if( this.subviews.length ) this.update()"/>
<attribute name="copyFrom" type="expression"/>
<method name="setAxis" args="a" >
this.axis = a;
this.sizeAxis = a == "x" ? "width" : "height"
</method>
<method name="addSubview" args="newsub">
this.updateDelegate.register( newsub, "on" + this.sizeAxis);
super.addSubview( newsub );
</method>
<method name="update">
<![CDATA[
if ( this.locked ) return;
var l = Math.min(this.subviews.length, copyFrom.subviews.length);
for(var i=0; i < l; i++) {
var src = copyFrom.subviews[ i ];
var dst = this.subviews[ i ];
dst.setAttribute(this.axis, src.getAttribute(this.axis));
dst.setAttribute(this.sizeAxis, src.getAttribute(this.sizeAxis));
}
]]>
</method>
</class>
<view name="headergroup">
<view name="header" initstage="early" bgcolor="#aaaaaa">
<text width="80" name="name">Name</text>
<text width="80" name="price">Price</text>
<simplelayout axis="x" spacing="20"/>
</view>
</view>
<view name="data" datapath="hotelresult:/item" ondata="this.processData();" >
<text name="name" multiline="true" datapath="name/text()"/>
<text name="price" multiline="true"/>
<copylayout axis="x">
<attribute name="copyFrom" init="parent.parent.headergroup.header" />
</copylayout>
<method name="processData">
//debug.write(this.datapath.getNodeName());
this.price.setText(this.datapath.getXPath("price/text()") * 1.10);
</method>
</view>
<simplelayout2 axis="y">
<attribute name="bgcolor" value="0xcccccc"/>
<attribute name="altbgcolor" value="0xf0f0f0"/>
</simplelayout2>
</canvas>
<text name="price" multiline="true"/>
<method name="processData">
//debug.write(this.datapath.getNodeName());
this.price.setText(this.datapath.getXPath("price/text()") * 1.10);
</method>
<canvas debug="true">
<dataset name="hotelresult">
<item>
<name>BUENA VISTA SUITES</name>
<price>$20</price>
</item>
<item>
<name>QUALITY SUITES MAINGATE EAST</name>
<price>$20</price>
</item>
<item>
<name>HOLIDAY INN MAINGATE WEST</name>
<price>$20</price>
</item>
<item>
<name>RAMADA INN RESORT</name>
<price>$20</price>
</item>
<item>
<name>BDOUBLETREE RESORT VILLAS</name>
<price>$20</price>
</item>
<item>
<name>DAYS SUITES MAINGATE EAST</name>
<price>$20</price>
</item>
<item>
<name>HILTON WALT DISNEY WORLD</name>
<price>$20</price>
</item>
<item>
<name>HOWARD JOHNSON MAINGATE EAST</name>
<price>$20</price>
</item>
</dataset>
<class name="simplelayout2" extends="layout" >
<attribute name="axis" value="y" onset="this.setAxis( axis );"
type="string" />
<attribute name="spacing" value="0"
onset="this.spacing = spacing;
if( this.subviews.length ) this.update()"/>
<attribute name="altbgcolor" type="number"
onset="this.altbgcolor = altbgcolor;"/>
<method name="setAxis" args="a" >
this.axis = a;
this.sizeAxis = a == "x" ? "width" : "height"
</method>
<method name="addSubview" args="newsub">
this.updateDelegate.register( newsub, "on" + this.sizeAxis);
if ( ! this.locked && this.subviews.length ){
var s= this.subviews[ this.subviews.length-1 ];
var p = s.getAttribute( this.axis ) +
s.getAttribute( this.sizeAxis );
if ( this.subviews.length ){
p += this.spacing;
}
newsub.setAttribute( this.axis , p ) ;
}
super.addSubview( newsub );
</method>
<method name="update">
<![CDATA[
if ( this.locked ) return;
var l = this.subviews.length;
var c = 0;
for(var i=0; i < l; i++) {
var s = this.subviews[i];
if(i % 2)
{
//debug.write("altcolor:" + this.altbgcolor);
s.setAttribute("bgcolor", this.altbgcolor);
//s.setBGColor(this.altbgcolor);
}
else
{
//debug.write("normalcolor:" +this.bgcolor);
s.setAttribute("bgcolor", this.bgcolor);
}
s.setAttribute( this.axis , c );
//trace("setAttribute after= " + this.axis);
c += this.spacing + s.getAttribute( this.sizeAxis ) ;
}
]]>
</method>
</class>
<class name="copylayout" extends="layout" >
<attribute name="axis" value="y" onset="this.setAxis( axis )"
type="string" />
<attribute name="spacing" value="0"
onset="this.spacing = spacing;
if( this.subviews.length ) this.update()"/>
<attribute name="copyFrom" type="expression"/>
<method name="setAxis" args="a" >
this.axis = a;
this.sizeAxis = a == "x" ? "width" : "height"
</method>
<method name="addSubview" args="newsub">
this.updateDelegate.register( newsub, "on" + this.sizeAxis);
super.addSubview( newsub );
</method>
<method name="update">
<![CDATA[
if ( this.locked ) return;
var l = Math.min(this.subviews.length, copyFrom.subviews.length);
for(var i=0; i < l; i++) {
var src = copyFrom.subviews[ i ];
var dst = this.subviews[ i ];
dst.setAttribute(this.axis, src.getAttribute(this.axis));
dst.setAttribute(this.sizeAxis, src.getAttribute(this.sizeAxis));
}
]]>
</method>
</class>
<view name="headergroup">
<view name="header" initstage="early" bgcolor="#aaaaaa">
<text width="80" name="name">Name</text>
<text width="80" name="price">Price</text>
<simplelayout axis="x" spacing="20"/>
</view>
</view>
<view name="data" datapath="hotelresult:/item" ondata="this.processData();" >
<text name="name" multiline="true" datapath="name/text()"/>
<text name="price" multiline="true"/>
<copylayout axis="x">
<attribute name="copyFrom" init="parent.parent.headergroup.header" />
</copylayout>
<method name="processData">
//debug.write(this.datapath.getNodeName());
this.price.setText(this.datapath.getXPath("price/text()") * 1.10);
</method>
</view>
<simplelayout2 axis="y">
<attribute name="bgcolor" value="0xcccccc"/>
<attribute name="altbgcolor" value="0xf0f0f0"/>
</simplelayout2>
</canvas>