Kalle,
Thanks a lot for posting the example! I will try it out, although I also
implemented one possible solution which I've attached below. I haven't
tested it fully yet, but it seemed to work quite efficiently at least with
one search parameter. It uses two different datasets by moving matching rows
from one with all rows to the other, which is then displayed in a grid. It
might not be the most elegant piece of coding, but hey.. :)
Mikko
-------------
<dataset name="myData">
<root>
<person name="Jones" />
<person name="Smith" />
<person name="Williams" />
</root>
</dataset>
<dataset name="visibleData">
<root />
</dataset>
<grid name="myview" datapath="visibleData:/root" shownitems="20">
<gridtext datapath="@nimi" width="100">First Name</gridtext>
</grid>
<method name="filterdata">
var filtertext = this.parent.filter.getText().toLowerCase();
/* clear visible dataset */
var dp = visibleData.getPointer();
dp.setXPath("root");
var ok = dp.selectChild();
while (ok && dp.getNodeName() != undefined)
dp.deleteNode();
dp = visibleData.getPointer();
dp.setXPath("root");
/* search for matching nodes */
var dp2 = myData.getPointer();
dp2.setXPath("root");
var ok = dp2.selectChild();
while (ok) {
var a = dp2.getNodeAttribute("name");
if (a.toLowerCase().indexOf(filtertext) != -1) {
dp2.setNodeAttribute("found", "true");
dp.addNodeFromPointer(dp2);
} else {
dp2.setNodeAttribute("found", "false");
}
ok = dp2.selectNext();
}
</method>
-----------------
-----Alkuperäinen viesti-----
Lähettäjä: Kalle Svartholm [mailto:[EMAIL PROTECTED]
Lähetetty: 22. joulukuuta 2006 19:01
Vastaanottaja: Mikko Valjento
Kopio: [email protected]
Aihe: Re: [Laszlo-user] Dataset filtering and problems with
contentdatapath on grid
Sorry for the delay.
I finally found a neat soulution to this:
grid.content.rowparent.replicator.setDatapath([yourDataPath]);
For filtering you'll probably want something like this:
grid.content.rowparent.replicator.setDatapath ("[EMAIL PROTECTED]'1']");
Hope it'll help you too.
Regards,
Kalle
On 12/17/06, Mikko Valjento < [EMAIL PROTECTED]> wrote:
This discussion about dataset and grid filtering seems to have been up
already last February.
http://www.openlaszlo.org/pipermail/laszlo-user/2006-February/002804.htm
l
Does anybody know if anything has been done about it, that is, is it
still
not possible to make 'views' or filtered instances of datasets which
could
then be reference for example by a grid component?
To me this would seem like an essential feature.
Regards,
Mikko
-----Alkuperäinen viesti-----
Lähettäjä: [EMAIL PROTECTED]
[mailto:[EMAIL PROTECTED] ]Puolesta Daniel Williams
Lähetetty: 13. joulukuuta 2006 18:16
Vastaanottaja: Kalle Svartholm
Kopio: [email protected]
Aihe: Re: [Laszlo-user] Problems with contentdatapath on grid
Kalle,
I had the same issue. The work around I found was to use a datapointer.
Within the datapointer I could manipulate the data before the grid got
the data.
Also it's my belief the contentdatapath was intended to be used as
filter on your data, not to modify the data.
But now looking back, you may want to try ds.setAttribute('rerunxpath',
true).
My two cents.
-Daniel
Kalle Svartholm wrote:
> Hi, guys!
> I wrote a filtering class for datasets, (it adds an attribute named
> removed=<true|false>) and works great.
> However when I apply the filter on a grid (i.e. modify the data in the
> dataset), its contentdatapath doesn't seem to be synced with the
> modified dataset.
>
> Here is an example:
> <grid name="myGrid" datapath="userData:/users[1]"
> contentdatapath="[EMAIL PROTECTED] = 'false']" initstage="late">
> <gridtext datapath="firstName/text()" width="100">First
> Name</gridtext>
> <gridtext datapath="lastName/text()" width="100">Last
Name</gridtext>
> <gridtext datapath="@removed" width="100">removed</gridtext>
> </grid>
>
> Is this the expected behaviour and is there a way to fix this?
> (It works great as long as I don't use any contentdatapath.)
>
> Regards,
> Kalle