View Full Version : grid class
johnagrandy
05-07-2003, 09:01 PM
have any grid classes been built for lps yet? preferably with some spreadsheet functionality ...
antun
05-07-2003, 09:33 PM
It's really easy to build a grid, which is why we don't have a class for it. Most of the time you'd just end up defining the layout for each application.
Do you have an example of the data you want to display? It has to be XML data. If you post a sample I can help you get it up and running.
-Antun
johnagrandy
05-07-2003, 10:04 PM
i was thinking in terms of properties, methods, & events on the cells ... maybe if someone had designed something generic ...
but you are probably right that "from scratch" is best ...
if you have any sample code (doesn't matter what the data is) i'd like to see it ...
also, charting ....
antun
05-07-2003, 10:35 PM
Have a look at the data tutorial, particularly under "Multiple rows of data":
http://www.laszlosystems.com/developers/learn/documentation/tutorials/data.php
Data replication is the concept of creating multiple instances of a view based on similar data. It's the foundation for building a grid. Here's a really quick and dirty example:
<canvas>
<dataset name="myGrid">
<shares>
<stock symbol="MSFT" name="Microsoft" value="25.99" quant="20" />
<stock symbol="ADI" name="Analog Devices" value="33.58"
quant="100" />
<stock symbol="BA" name="Boeing" value="28.38" quant="56" />
<stock symbol="FDX" name="Federal Express" value="61.19"
quant="44" />
</shares>
</dataset>
<class name="myText" extends="text" bgcolor="0xffffff" />
<view datapath="myGrid:/shares" bgcolor="0xe5e5e5">
<simplelayout axis="y" spacing="2" />
<view name="stocksRow" datapath="stock">
<simplelayout axis="x" spacing="2" />
<myText datapath="@symbol" width="50" />
<myText datapath="@name" width="150" />
<myText datapath="@value" width="50" name="price" />
<myText datapath="@quant" width="50" name="quant" />
<myText>
<method event="oninit">
var quantity = parent.quant.getText() * 1;
var price = parent.price.getText() * 1;
this.setText( quantity * price );
</method>
</myText>
</view>
</view>
</canvas>
The dataset in this case is just a static inline XML document that contains some stock information. The first 4 columns are bound to attributes from the data (symbol, name, value and quantity). The last column is calculated from the product of the quantity and the price.
Run it on your LPS and have a play with it if you want. I wrote a quick class to have a text field with a white background (so that I could mock up the gridlines quickly).
As for charting, bar and scatter charts would be fairly straightforward to do. Data replication doesn't have to result in boring columns of text - for example you could control a view's x or y position based on data. The world clock app here:
http://www.laszlosystems.com/products/
... uses data replication to define and position the cities around the world.
-Antun
johnagrandy
05-10-2003, 11:50 AM
thanks Antun. do you know where i could obtain some xml format historical stock prices data? for example, a year's worth of daily data for msft,intc,csco,orcl .... ? (or really, anything ... as long as its free).
antun
05-10-2003, 07:49 PM
Have you looked at XMethods?
http://www.xmethods.net/
-Antun
vBulletin® v3.8.4, Copyright ©2000-2012, Jelsoft Enterprises Ltd.