[Laszlo-user] Understanding grid
Yang
a1pwak602 at sneakemail.com
Wed Jul 11 18:22:11 PDT 2007
Hi, I'm trying to understand grid and how it creates/replicates
columns/cells (and hopefully learn a ton about Laszlo). Any answers
would be greatly appreciated! I've divided up this email into two
parts.
BTW, if any Laszlo devs are listening, it seems to me that grid is one
of the most frequently asked-about components (on the list and in the
forums). It is one of the more complex components, to be sure. Perhaps
more attention can be afforded to this component, in terms of built-in
features and extensibility hooks - or at least some documentation
walking through how basegrid works and how to extend it (in
non-trivial ways).
1) Changing Columns
grid expects the set of columns to never change. According to
http://forum.openlaszlo.org/showthread.php?s=&threadid=1952, I need to
call init() after updating the dataset.
I produced a small test case showing that this is insufficient. See
the attached change-cols.lzx. The columns don't change (but the rows
do disappear). If I explicitly call inferColumns(), that causes new
columns to appear (each time inferColumns() is called), but old ones
remain.
I also get an error in Debug - once when the dataset updates, and once
just for adding an "ondata" handler to the grid:
WARNING: Redefining .rowparent.replicator from Lazy clone manager in
LzView name: rowparent to «lz.basegridrow»
2) Understanding Replication
In order to get to the bottom of the above behavior, I'm currently
trying to understand the way columns and cells are created in grids.
In basegrid.makeCellsAndColumns(), I see:
var r = new _rowclass ( content.rowparent , initArgs, cells , true );
new LzDatapath( r , { replication : "lazy" ,
xpath : this.contentdatapath ,
spacing : this.spacing } );
However, in the following, I get errors:
<canvas>
<simplelayout axis="y"/>
<dataset name="maindata" oninit="classroot.doit()" ondata="classroot.doit()">
<maindata>
<item>
<cell1>alpha</cell1>
<cell2>beta</cell2>
<cell3>gamma</cell3>
</item>
<item>
<cell1>delta</cell1>
<cell2>epsilon</cell2>
<cell3>zeta</cell3>
</item>
</maindata>
</dataset>
<script>
Debug.write("running");
var t = new LzText ( canvas, { name: "replicator" } );
new LzDatapath( t , { replication: 'lazy',
xpath: 'maindata:/maindata/item/*/text()' } );
</script>
</canvas>
The output is:
running
WARNING: Redefining #replicator from #replicator to Lazy clone manager
in This is the canvas
ERROR: setHeight cannot be called on the canvas.
Yet the replication seems to be have taken place. What are these errors about?
Also, what are those extra parameters to _rowclass (which should by
default be basegridrow)? I couldn't find any documentation on this, or
on constructors in Laszlo (aside from LzNode.construct(), which only
takes 2 args), or how the "new" keyword works.
Lastly, why is there a "spacing" attribute initialized in the LzDatapath?
Thanks a lot for any help!
-------------- next part --------------
A non-text attachment was scrubbed...
Name: change-cols.lzx
Type: application/x-lzx
Size: 838 bytes
Desc: not available
Url : http://www.openlaszlo.org/pipermail/laszlo-user/attachments/20070711/2434f401/change-cols.bin
More information about the Laszlo-user
mailing list