View Full Version : Adding tabelements with data loop ???
marcovth
10-19-2004, 07:13 AM
Hello ...
I am trying to loop through a dataset and add tabelements to a tabslider?
Is there a <loop> tag?
<tabslider datapath="query:/List/record" width="150" height="100">
<tabelement text="$path{'@name'}"><text>Hi</text></tabelement>
<scrollbar/>
</tabslider>
- Marco.
marcovth
10-19-2004, 10:04 AM
I checked out how it's being done with Flex:
<mx:Accordion width="200" height="1200">
<mx:Repeater id="albums" dataProvider="{query.result.List.record}">
<mx:VBox label="{albums.currentItem.NAME}">
<mx:Label text="This is album {albums.currentItem.NAME}"/>
</mx:VBox>
</mx:Repeater>
</mx:Accordion>
They have a repeater tag. I searched through the laszlo
docs, but nothing about a repeater or loop tag.
- Marco.
marcovth
10-19-2004, 10:12 AM
In laszlo, I assume, it should look like this:
<tabslider width="150" height="100">
<loop id="albums" datapath="query:/List/record">
<tabelement text="${albums.currentItem.NAME}">
<text>This is album ${albums.currentItem.NAME}></text>
</tabelement>
<scrollbar/>
</loop>
</tabslider>
- Marco.
Is use Laszlo replication facilities.
Look at ch 10 section 2.1
Also look at the Data examples in the Laszlo Explorer (http://www.laszlosystems.com/lps/laszlo-in-ten-minutes/).
In brief, if a view has a datapath attribute that matches multiple elements of a dataset, it is repeated once for each element that it matches.
antun
11-02-2004, 10:55 AM
That's right. In Laszlo, repeating is handled using data replication. See the Developer's Guide chapter on data, in particular the replication section:
http://www.laszlosystems.com/lps-2.2/docs/guide/databinding.html#databinding.replication
-Antun
Originally posted by dkim
Is use Laszlo replication facilities.
Look at ch 10 section 2.1
jasonj
04-14-2005, 04:42 AM
I've been working with the dashboard example, trimming it down to learn about laszlo. My problem lies in trying to layout a repeating set of text within a tabelement. I thought I was following the data source examples properly but my text elements are not tiling in the layout; they all overlap each other instead.
Any pointers would be most appreciated.
-jason
<class name="newsTab" extends="dashTab"
width="${immediateparent.width}"
tabLabelColor="80705A"
tabLabelBrightness="-60"
tabBarColor="E0C49D"
tabBarBrightness="-80" />
....
<dashTabElement name="Text" bgcolor="#F2E9DA">
<newsTab tabLabel="Text" />
<view id="enttest3" y="19" datapath="news:/news/item">
<text fontsize="14" text="$path{'title/text()'}"/>
<simplelayout axis="y"/>
</view>
</dashTabElement>
antun
04-14-2005, 04:50 AM
Does this datapath match more than once: news:/news/item? If so, it will be your view that is getting replicated, not just the text field. Try moving the simplelayout up one view, so that it affects the view, not the text field. Or remove the view, and give the text field the full datapath (news:/news/item/title/text()).
-Antun
jasonj
04-14-2005, 05:24 AM
Adding <simplelayout axis="y" /> to the outer view did the trick. I left the inner one to handle multiple text lines.
Thanks.
Also, what's the difference between
<text fontsize="14" text="$path{'title/text()'}"/>
and
<text fontsize="14" datapath = "title/text()" />
?
Now, is there an easy way to alternate a background color on even/odd rows? That would be most excellent!
-jason
-- improved element ---
<dashTabElement name="Text" bgcolor="#F2E9DA">
<newsTab tabLabel="Text" />
<simplelayout axis="y"/>
<view id="enttest3" y="19" datapath="news:/news/item">
<simplelayout axis="y"/>
<text fontsize="14" text="$path{'title/text()'}"/>
<text fontsize="14" text="$path{'intro/text()'}"/>
</view>
</dashTabElement>
--- Sample Data ---
<?xml version="1.0" encoding="ISO-8859-1" ?>
<!-- Default OPML for Laszlo Link Box: A Blogging Widget -->
<!-- Users may modify to suite their needs -->
<news>
<item>
<title>Title One</title>
<intro>Hi there #1</intro>
</item>
<item>
<title>Title Two</title>
<intro>Hi there #2</intro>
</item>
<item>
<title>Title Three</title>
<intro>Hi there #3</intro>
</item>
</news>
antun
04-14-2005, 05:54 AM
Also, what's the difference between
<text fontsize="14" text="$path{'title/text()'}"/>
and
<text fontsize="14" datapath = "title/text()" />
The former is a data constraint on the text attribute, and the latter is data binding a text field to an XPath. Since <text> sets its text attribute to any data it is bound to, they are functionally the same in this case. You'd use the former syntax if you wanted to do something like:
<view x="$path{'@myxposition'}" ... />
Also, $path{} bindings cannot be absolute XPaths (although there is a feature request for that I believe). A datapath can be absolute.
For the background color, you can use the XPath, "position()" of the view that is bound to the repeated XPath to find the number of the node:
<attribute name="mypos" value="$path{'position()'}" type="number" />
... and then you could add a constraint on the background color dependant on whether that was odd or even.
-Antun
jasonj
04-14-2005, 08:28 AM
Ok, I'm interested in capturing and restoring some basic settings (eventually per user) like window position and size (for starters).
I'd like to make this robust and would like to find the window (or other component) given an input string.
Example:
<settings>
<window key="myNews" x="100' y="100' width="100" ht="100" />
...
</settings>
Is there a way to something like this?
var aWin = windows[setting.key];
aWin.x = setting.x;
...
Any ideas?
thanks,
jason
jasonj
04-15-2005, 06:22 AM
In trying to set a database driven app I thought subclassing dataset would be a great approach.
So I defined a simple class (below) but now am having difficulty getting it instantiated.
What am I missing?
thanks,
Jason
<OSender name="sender" src="dbinterface.cgi" />
<class name="OSender" request="true" type="http">
<method name="update" args="obj">
var p=new LzParam();
for (var slot in obj) {
p.addValue( slot, obj[slot], true);
}
this.setQueryString( p );
Debug.write("send:", p);
this.doRequest();
</method>
<method name="delete" args="obj">
var p=new LzParam();
p.addValue( "pk", obj.pk, true);
this.setQueryString( p );
this.doRequest();
</method>
</class>
vBulletin® v3.8.4, Copyright ©2000-2012, Jelsoft Enterprises Ltd.