View Full Version : grid with node-based columns
mcgaffin
05-27-2004, 07:56 AM
I have an xml data source that I would like to display in a grid, but its columns are definied like:
<data>
<row>
<name />
<address />
</row>
</data>
instead of:
<data>
<row name="" address="" />
</data>
Can I make the grid component dynamically create columns from the subnode? By default, it only seems to work with attribute-based columns.
The structure of the xml data is dynamic, so I can't just create <gridcolumn> definitions with the appropriate datapath for each column.
Thanks,
david
What you want to do is to similar to what the basegrid function "inferColumns" does. In fact, you could override this method in your instance.
andrewbruno
03-15-2005, 08:09 PM
This answer doesnt make sence??
I am trying to work out the same thing.... Been searching and testing for hours...
How can I use the <node> xml instead of attribute xml, as described below?
<canvas>
<dataset name="myData">
<booklist>
<bookItem>
<id>book4</id>
<bookName>
Beginning Programming with Java for Dummies
</bookName>
<bookDescription>
User-friendly guide offers easy-to-follow
instructions on Java programming basics and
strategies for writing code. Written in a light,
humorous style with numerous examples. Includes
tear-out cheat sheet, illustrations, and index.
</bookDescription>
</bookItem>
<bookItem>
<id>book3</id>
<bookName>Java in a Nutshell - Fourth Edition</bookName>
<bookDescription>
Still contains an accelerated introduction to the
Java programming language and its key APIs so you
can start writing code right away.
</bookDescription>
<borrower>andrewb</borrower>
<dateBorrowed>2005-03-16 15:02:27.255 EST</dateBorrowed>
</bookItem>
<bookItem>
<id>book6</id>
<bookName>
Effective Java Programming Language Guide
</bookName>
<bookDescription>
Written for the working Java developer, Joshua
Bloch's Effective Java Programming Language
Guide provides a truly useful set of over 50 best
practices and tips for writing better Java code.
With plenty of advice from an indisputable expert in
the field, this title is sure to be an indispensable
resource for anyone who wants to get more out of
their code.
</bookDescription>
</bookItem>
</booklist>
</dataset>
<simplelayout axis="y" spacing="20" />
<view name="myTextView">
<simplelayout axis="y" />
<view name="rowOfData"
datapath="myData:/booklist[1]/bookItem">
<simplelayout axis="x" spacing="4" />
<text datapath="bookName/text()" />
<text datapath="bookDescription/text()" />
</view>
</view>
<view name="myTable3">
<!--
contentdatapath="*"
By default, this is set to "*", meaning all of the nodes
underneath the datacontext of the grid.
-->
<grid datapath="myData:/booklist[1]" contentdatapath="*">
<gridcolumn showheader="false" width="50">
<view bgcolor="#CCCCCC" width="${parent.width}"
placement="header" height="${parent.immediateParent.height-1}" />
<text datapath="position()" />
</gridcolumn>
<gridcolumn>
<text datapath="/bookItem/bookName/text()" />
</gridcolumn>
<!--
<gridtext datapath="bookName/text()">Name</gridtext>
<gridtext datapath="bookDescription/text()">Description</gridtext>
-->
</grid>
</view>
</canvas>
meiriko
07-06-2007, 04:47 PM
Take a look at:
http://forum.openlaszlo.org/showthread.php?t=6813
vBulletin® v3.8.4, Copyright ©2000-2012, Jelsoft Enterprises Ltd.