PDA

View Full Version : $path and grid / attribute accessors


kermit
10-24-2008, 12:02 AM
Hello,

Can someone explain me why $path do not work with grid component?

Next question : there is several way to access attribute, which one is the correct one. I get a deprecated warning in debug console for getAttribute, it do no behave as this['attribute'], I think of enabled attribute for instance. Can someone clarify ?



<canvas debug="true">
<include href="../lps/components/utils/layouts/simplelayout.lzx" />
<include href="../lps/components/lz/gridcolumn.lzx" />

<dataset name="ds">
<items>
<item name="n1" value="1"/>
<item name="n2" value="2"/>
<item name="n3" value="3"/>
</items>
</dataset>

<simplelayout axis="y" spacing="15" ></simplelayout>

<grid datapath="ds:/items" contentdatapath="item">
<attribute name="test" value="$path{'@name'}"/>
<handler name="ontest" args="data">
Debug.write("ontest: " + data);
Debug.write("this['test']: " + this['test']);
Debug.write("this.getAttribute('test'):"
+ this.getAttribute('test'));
Debug.write('test: ' + test);
Debug.write('this.test: ' + this.test);
</handler>
<gridtext datapath="@name"/>
</grid>


<grid datapath="ds:/items" contentdatapath="item">
<gridtext datapath="@name">
<attribute name="test" value="$path{'@name'}"/>
<handler name="ontest" args="data">
Debug.write("ontest: " + data);
Debug.write("this['test']: " + this['test']);
Debug.write("this.getAttribute('test'):"
+ this.getAttribute('test'));
Debug.write('test: ' + test);
Debug.write('this.test: ' + this.test);
</handler>
</gridtext>
</grid>


</canvas>



regards,

senshi
10-25-2008, 12:41 PM
Can someone explain me why $path do not work with grid component?
Your grid's datapath selects "ds:/items", but that data-element hasn't got a "name" attribute. So that won't work.

Next question : there is several way to access attribute, which one is the correct one. I get a deprecated warning in debug console for getAttribute, it do no behave as this['attribute'], I think of enabled attribute for instance. Can someone clarify ?
"getAttribute()" was deprecated because it just returns the value, so there is no point to perform an extra function call.


The implementation was similar to this code:

function getAttribute (attr) {
return this[attr];
}