View Full Version : Laszlo newb needs help with a couple things
thecow
04-30-2004, 04:08 AM
Hey all, I am trying this product out after getting frustrated with flex. I am really liking it so far, kudos.
Anyway, I have a couple questions. The first one is really simple. How do I fill an editbox with a variable, like I am trying to below.
<canvas>
<view layout="axis:x; spacing:12">
<view layout="spacing:4">
<combobox id="jobs_job" width="120" dataoption="lazy" editable="false" defaulttext="choose one..." shownitems="10">
<textlistitem datapath="jobSrv:/Jobs/JobNumber" text="$path{'label/text()'}"
value="$path{'data/text()'}"/>
</combobox>
</view>
<view layout="spacing:4">
<edittext width="280" name="jobs_nomenclature"> jobs_job.top.subviews[3].getText()</edittext>
</view>
</view>
</canvas>
Second question, how would I get started on modifying a combobox. I realllly need to have one that uses soft-search, like in vb. Flex and html use one that softsearch on the first letter only, but that isn't going to cut it. I need one that goes all the way (to jump through a huge list of data that all starts with the same letter).
Last question, I am having trouble figuring out the grid syntax. Can someone give me an example using the data path in the above code. I will be getting all of my xml in a format very close to that, so it should help me alot.
Any help is greatly appreciated. Thanks.
thecow
04-30-2004, 07:15 AM
Ok, I have figured out the first problem of getting the variable into the edittext by using ${jobs_job.value}.
I am still looking for help on the second two questions if anyone has any input. Thanks!!
antun
04-30-2004, 11:49 AM
Second question, how would I get started on modifying a combobox.
Have a look at this thread - it outlines different approaches for customizing components:
http://www.laszlosystems.com/developers/community/forums/showthread.php?s=&threadid=847
Bear in mind that a combobox component is a lot more complicated than a window component, so that option might not be such a great idea in your case. In fact it might well be the single most complicated component to engineer correctly. You can browse the LZX source for combobox to get a feel for the various problems that were solved in its construction.
I tried tinkering with the onkeydown event to capture the key that was necessary in order to begin the keyboard-nav you mentioned, and discovered a bug in combobox: It wasn't sending the key code for the onkeydown event, so you wouldn't know what key the user had just pressed.
I'm attaching a patched combobox so you can get started, but this isn't an official supported fix. Combobox will be properly fixed in an upcoming release.
You should be able to plonk the attached file in: C:\Program Files\Laszlo Presentation Server 2.1\jakarta-tomcat-4.1.12\webapps\lps-2.1\WEB-INF\lps\components\lz
... and use it as outlined below:
<canvas debug="true">
<debug x="250" />
<include href="lz/keydowncombobox.lzx" />
<dataset name="items">
<item value="item1" >A item one</item>
<item value="item2" >B item two</item>
<item value="item3" >C item three</item>
<item value="item4" >D item four</item>
</dataset>
<keydowncombobox x="5" y="5"
editable="false"
width="130"
shownitems="3"
defaulttext="choose one..."
oninit="LzFocus.setFocus(this)">
<textlistitem name="items"
datapath="items:/item" text="$path{'text()'}"
value="$path{'@value'}"/>
<method event="onkeydown" args="k">
Debug.write( "onkeydown sent" );
Debug.write( "key: " + k );
// Loop through all of the replicated items in the combobox
// and write out the first letter of it's text field.
for ( var i in this.items.clones ) {
var c = this.items.clones[i];
var dispText = c.text;
var firstLetter = dispText.charCodeAt(0);
Debug.write( "The first letter is: " + firstLetter );
if ( firstLetter == k ) {
// The key code for the pressed key matches the
// key code at the start of this item's text
this.select( c );
return;
}
}
</method>
</keydowncombobox>
</canvas>
This is really to get you started. This won't work with dataoption="lazy", nor with comboboxes that are not data replicated. You'd have to write a different method, because instead of having items.clones, a combobox without data-replicated items would have subviews.
Also, you'd have to add some logic in there to deal with capitals/lowercase key codes. I've taken the lazy option and put capitals as the first letters of the items in combobox, since the onkeydown event sends the value for the capital letter. Should be easy to fix though.
Hope this helps!
-Antun
thecow
04-30-2004, 12:24 PM
Thank you very much for doing what you can to help me get started. I will probably start working on this monday, but you have me scared about working it into a combobox.
If I do get it going, it would have to be able to work with dataoption=lazy, because without that my load time is extremely slow.
Anyway, thanks again and if I get it finished I will post it here. I'm sure everyone would want softsearch capabilities.
Thanks!!!
hugolon
01-21-2005, 04:05 PM
Hi there!
I read your thread and thought this might be helpful.
I just made my own combobox with softsearch capabilities.
Hope you can use it.
I attached the code again here in cas you cant find my other thread.
Enjoy
vBulletin® v3.8.4, Copyright ©2000-2012, Jelsoft Enterprises Ltd.