PDA

View Full Version : Does Grid refresh, or not?


frethog
01-24-2008, 12:45 PM
My expectation was that upon clicking button "TwoOdd" the grid in the "Even" tabpane would no longer display the "Two" row, and that it would appear in the grid in the "Odd" tabpane.

So it appears that a refresh occurs (as evidenced by "o" to "e" in the "All" tabpane), but that it doesn't occur completely (as evidenced by the "Two" row in "Even" and "Odd" tabpanes staying in it's previous location).

Given that...
"All" having: contentdatapath="Row"
"Even" having contentdatapath="Row[@category='e']"
"Odd" having contentdatapath="Row[@category='o']"
...I would think my expectations are reasonable.

Further, I've unsuccessfully tried "updateData" "setxpath" and rebinding with "setAttribute('datapath" in order to encourage the refresh.

Any ideas on what I'm overlooking? :confused:


<canvas>
<dataset name="numDS">
<Rows>
<Row category="o"><case>One</case></Row>
<Row category="e"><case>Two</case></Row>
<Row category="o"><case>Three</case></Row>
<Row category="e"><case>Four</case></Row>
</Rows>
</dataset>
<view name="todo_list_view" layout="axis:y">
<view name="buttons" layout="axis:y">
<button name="make2e" text="TwoEven" onclick="numDS.getPointer().xpathQuery('numDS:/Rows/Row[2]').setAttr('category','e')"/>
<button name="make2o" text="TwoOdd" onclick="numDS.getPointer().xpathQuery('numDS:/Rows/Row[2]').setAttr('category','o')"/>
</view>
<tabs name="todo_tabs" style="bluecolors" x="12">
<tabpane name="allTab">All
<grid datapath="numDS:/Rows" contentdatapath="Row" name="myGrid">
<gridcolumn name="myGridColumn" >
Number <text datapath="case/text()" />
</gridcolumn>
<gridtext datapath="@category" editable="false">
Category
</gridtext>
</grid>
</tabpane>
<tabpane bgcolor="#CECECE" name="EvenTab">Even
<grid datapath="numDS:/Rows" contentdatapath="Row[@category='e']" name="myGrid">
<gridcolumn name="myGridColumn" >
Number <text datapath="case/text()" />
</gridcolumn>
<gridtext datapath="@category" editable="false" >
Category
</gridtext>
</grid>
</tabpane>
<tabpane bgcolor="#CECECE" name="OddTab">Odd
<grid datapath="numDS:/Rows" contentdatapath="Row[@category='o']" name="myGrid">
<gridcolumn name="myGridColumn" >
Number <text datapath="case/text()" />
</gridcolumn>
<gridtext datapath="@category" editable="false" >
Category
</gridtext>
</grid>
</tabpane>
</tabs>
</view>
</canvas>

senshi
01-25-2008, 02:03 AM
Datapaths with XPath-Attribute-Predicates don't get updated when you change an attribute. I guess this was made to get better performance, because listening on all attribute changes can be quite performance-heavy. To workaround this, you just need to provoke a, let's say more impact change, i.e. by setting the childNodes-property (see below).


<canvas debug="true" >
<dataset name="numDS">
<Rows>
<Row category="o"><case>One</case></Row>
<Row category="e"><case>Two</case></Row>
<Row category="o"><case>Three</case></Row>
<Row category="e"><case>Four</case></Row>
</Rows>
</dataset>

<view datapath="numDS:/Rows" layout="axis:x; spacing:5" >
<view layout="axis:y" >
<text datapath="Row[@category='o']" text="${this.cat + ' - ' + this.casetext}" >
<attribute name="cat" value="$path{'@category'}" type="string" />
<attribute name="casetext" value="$path{'case/text()'}" type="string" />
</text>
</view>
<view layout="axis:y" >
<text datapath="Row[@category='e']" text="${this.cat + ' - ' + this.casetext}" >
<attribute name="cat" value="$path{'@category'}" type="string" />
<attribute name="casetext" value="$path{'case/text()'}" type="string" />
</text>
</view>

<button text="TwoEven" onclick="numDS.getPointer().xpathQuery('numDS:/Rows/Row[2]').setAttr('category','e')"/>
<button text="TwoOdd" onclick="numDS.getPointer().xpathQuery('numDS:/Rows/Row[2]').setAttr('category','o')"/>

<button text="TwoEven (working)" >
<handler name="onclick" >
numDS.getPointer().xpathQuery('numDS:/Rows/Row[2]').setAttr('category','e');
var rows = numDS.getPointer().xpathQuery('numDS:/Rows');
rows.setChildNodes(rows.childNodes);
</handler>
</button>
<button text="TwoOdd (working)" >
<handler name="onclick" >
numDS.getPointer().xpathQuery('numDS:/Rows/Row[2]').setAttr('category','o');
var rows = numDS.getPointer().xpathQuery('numDS:/Rows');
rows.setChildNodes(rows.childNodes);
</handler>
</button>
</view>
</canvas>