It's possible this was recently fixed:
http://jira.openlaszlo.org/jira/browse/LPP-2339
On 2008-10-24, at 16:07EDT, Paulo Scardine wrote:
Hi guys,
I use lz.list frequently. When using a large dataset, I always use
textlistitem with lazy replication. The problem is that if the list
has an item selected, and you scroll down the list, the selected
textlistitem will be reused. This causes some unpleasant/
inconsistent behavior: another random entry in the list will get
selected (the one which reuse the same textlistitem from the
previous selection); list.getSelection() will reflect the new value.
Automatically selecting another random entry just scrolling down is
unexpected; also, in this case onselect event will not fire.
I think the behavior I get when using the following hack is more
consistent with similar widgets from other toolkits:
<class name="xtd_list" extends="list">
<attribute name="selectedValue" value="null"/>
<handler name="onselect" args="d">
this.selectedValue = d.value;
</handler>
<method name="getValue">
return this.selectedValue;
</method>
<method name="clearSelection" args="keepSelectedValue">
super.clearSelection();
if(!keepSelectedValue) {
this.selectedValue = null;
}
</method>
</class>
<class name="xtd_textlistitem" extends="textlistitem">
<handler name="ondata" args="d">
if(this.value == parent.selectedValue) {
parent.select(this);
} else if(this.selected) {
parent.clearSelection(true);
}
</handler>
</class>
This makes only works with single selection and if "value" is unique
for each item, which is almost always true for me, but I'm wondering
if someone would came up with a more generic or elegant solution.
Thanks in advance,
--
Paulo Scardine
<!-- begin testcase -->
<dataset name="ds">
<records>
<record value="1">Value1</record>
<record value="2">Value1</record>
<record value="3">Value1</record>
<record value="4">Value1</record>
<record value="5">Value1</record>
<record value="6">Value1</record>
<record value="7">Value1</record>
<record value="8">Value1</record>
<record value="9">Value1</record>
<record value="10">Value10</record>
<record value="11">Value11</record>
<record value="12">Value12</record>
<record value="13">Value13</record>
<record value="14">Value14</record>
<record value="15">Value15</record>
<record value="16">Value16</record>
<record value="17">Value17</record>
<record value="18">Value18</record>
<record value="19">Value19</record>
</records>
</dataset>
<xtd_list width="200" height="60">
<xtd_textlistitem textlistitem text="$path{'text()'}"
value="$path{'@value'}">
<datapath xpath="local:parent.parent.dscasos:/records/
record" replication="lazy"/>
</xtd_textlistitem>
</xtd_list>
<!-- end testcase -->