PDA

View Full Version : Help with grid and state please


transistor
10-15-2007, 02:21 PM
Hi.
Here's what I am trying to do:
I have a state, which consists of a view a dataset and a grid.

<state name="prodList" apply="false">
<view name="prodListView" width="100%" height="100%">
<dataset name="listaProd" type="http" request="false" src="http://127.0.0.1/dharma/administration/scripts/productos.php" />
<grid datapath="listaProd:/catalogo" contentdatapath="productos/item" />
</view>
</state>

They are located in a library file that is included in the main canvas

<include href="library.lzx"/>

This view is shown when a selection from the menu takes place

onselect = prodList.apply();

The project compiles ok, but when I select the menu, I get this error:

__LZgetNodes: p is null in Datapath for grid

If I place the dataset and grid inside the main canvas, it shows the grid just fine.

What am I doing wrong?
Thank you

senshi
10-16-2007, 12:33 AM
Most likely you want to use local-datasets (http://www.openlaszlo.org/lps3/docs/guide/databinding.html#d0e21750):


<state name="prodList" apply="false">
<view name="prodListView" width="100%" height="100%">
<dataset name="listaProd" type="http" request="false" src="http://127.0.0.1/dharma/administration/scripts/productos.php" />
<grid datapath="local:parent.listaProd:/catalogo" contentdatapath="productos/item" />
</view>
</state>

transistor
10-16-2007, 02:17 PM
Thank you Senshi
Unfortunately local dataset didn't work, but this did:

At my library.lzx I created an empty dataset

<dataset name="listaProd"/>

Then I created a function to load the dataset

function loadProd() {
listaProd.setSrc("http://127.0.0.1/dharma/administration/scripts/productos.php");
listaProd.doRequest();
}

Then, at the state

<state name="prodList" apply="false" onapply="loadProd()">
<view name="prodListView" width="100%" height="100%" y="30" x="3">
<grid datapath="listaProd:/catalogo" contentdatapath="productos/item" />
</view>
</state>

Works! :)
I don't know what all the implications are using this approach, but I can tell that I like the fact that this doesn't load the dataset until it is applied or shown, thus load time for the application is pretty fast.