View Full Version : Depending upon one combo box selection, another combo box values needs to populate
mallesh
01-05-2004, 09:31 PM
Hi Antun,
Depending upon one combo box selection, another combo box values needs to populate .How to do this?
I mean when i select "Asia" from the first combobox from the below dataset,the second combobox should dynamically populated with the content of the second dataset shown below.
<dataset name="Continentslist" >
<Continents> <Continent>Australia</Continent>
<Continent>Asia</Continent>
<Continent>Europe</Continent>
<Continent>NorthAmerica</Continent>
</Continents>
</dataset>
<dataset name="Countrylist" >
<Countries> <Country>India</Country>
<Country>China</Country>
<Country>Japan</Country>
<Country>Korea</Country>
</Countries>.....
</dataset>
antun
01-06-2004, 09:14 AM
What version of the LPS are you running on?
-Antun
mallesh
01-07-2004, 06:27 AM
Hi Antun,
I am using lps-1.0.3 and combobox is working well.But my problem is, when u select an item from the first combobox (say "Asia" from first combobox), the second combobox will populate with the dataset containing countries in the Asia (as mentioned in the second datset).and if u select the "North america" from the first combo,the second combo must populate with the contries in that continent and so on..
For that,how can i set the "itemfield" and "datapath" of the second combobox?
In html, we can write the script to populate the second combo by getting the data from the database.
so how can i do it in laszlo?
I can write the as many dataset as required.but how to link these datasets to the second combobox?
Thanks alot
Mallesh.
antun
01-07-2004, 10:43 AM
The v1 components aren't really designed to have their datapath set at run-time. This is a new feature of the 2.0 components. That said, it may be possible for you to extend the combobox class, and tweak it to suit your needs.
However, I'm not sure that this is the best course of action for you. The whole model of clicking on one pull-down menu, to populate another pull-down menu with more granular options came about as a result of the restrictions placed upon developers by HTML form elements.
If you're using Laszlo, it seems counterproductive to try to reproduce HTML/JavaScript behavior when you can do so much more.
A really good, intuitive example of a drill-down user interface is in the Yahoo Personalization Tool. See the demo here:
http://www.laszlosystems.com/success/customer/resources/yahoo_pw_tour04.html
... you will have to click 3 "Continue" times to get to the relevant part of the demo. Notice how in the right hand pane (under "More News") the user is drilling down to a selection list?
-Antun
mallesh
01-08-2004, 05:14 AM
Hi Antun,
Yes.It is right approach to do it instead of using combobox.But How do i implement this into my application.Any exmaples for reference?
Thanks
Mallesh
antun
01-08-2004, 09:20 AM
There aren't any examples that I know of. You might want to check out the tree on myLaszlo.com:
http://www.mylaszlo.com/lps/max/treecontrol/treecontrol.lzx
My approach would be to have a view that contained the replicated continents. When a continent is clicked, slide another view (the countries view) with an opaque background over the continents view. Set the countries view's datapath at run-time. The countries view would probably have a scrollbar.
-Antun
mallesh
01-09-2004, 05:40 AM
Hi Antun,
Is it possible to set the itemfields and datapath of a combobox to the dataset generated by the serverside script (like JSP which interact with database)?
what i mean is, instead of setting the itemfield and datapath of the combobox,change the content of the dataset generated (by getting the data from the database) though the jsp).
I tried that but could'nt able to get the data from the database.But when i call the doRequest(), the length of the combobox was adjusted to the actuall length of the data.(i mean, when i request with continent is "NorthAmerica" with only 4 countries there is no scroll bar with combobx,but if i request with "Asia" the combobox with scrollbar appears in the combobox).But not getting the actual items(data).
<dataset name="subcategorydst" src="subcategory.jsp" autorequest="false" type="http" />
<mycombobox x="90" y="80" width="152" shownitems="4"
itemfield="subcategorydst:/Category/CategoryImg/Title/text()"
datapath="subcategorydst:/Category/CategoryImg/Title[1]/text()"
" >
<method name="returnText">
this.getTextDel.unregisterAll();
var typ = this.top.subviews[3].getText();
Debug.write("SUBCATEGORY"+typ);
var d = canvas.datasets.gallerydset;
//d.setQueryString({ category : typ } ) ;
//d.doRequest();
</method>
Thanks
Mallesh.
antun
01-09-2004, 11:04 AM
I just did a quick test of changing the data using a datapointer, and had no luck. The Redmond components that ship with LPS 1.0.x are not really designed to be used with data that changes - at least the combobox.
Like I said before, it might be possible for you to extend (or re-write) the combobox to achieve this, but I really don't feel that it's the right thing to do given what effect you're trying to create (assuming this is still the same goal - i.e. drilling down through a selection of continents to a specific country).
-Antun
mallesh
03-19-2004, 09:09 PM
Hi
quote: from last reply
--------------------------------------------------
The v1 components aren't really designed to have their datapath set at run-time. This is a new feature of the 2.0 components. That said, it may be possible for you to extend the combobox class, and tweak it to suit your needs.
-------------------------------------------
when u select an item from the first combobox (say "Asia" from first combobox), the second combobox will populate with the dataset containing countries in the Asia (as mentioned in the second datset).and if u select the "North america" from the first combo,the second combo must populate with the contries in that continent and so on..
For that,how can i set the "itemfield" and "datapath" of the second combobox?
In html, we can write the script to populate the second combo by getting the data from the database.
is it possible using LPS2.0 or LPS2.1?
Thanks
Mallesh
antun
03-22-2004, 09:55 AM
This works in 2.1:
<canvas width="800" height="800" debug="true">
<dataset name="countriesContinents">
<item value="asia" >Asia
<item value="india">India</item>
<item value="japan">Japan</item>
</item>
<item value="europe" >Europe
<item value="italy">Italy</item>
<item value="france">France</item>
</item>
<item value="northAmerica" >North America
<item value="italy">Canada</item>
<item value="france">USA</item>
<item value="france">Mexico</item>
</item>
</dataset>
<combobox x="5" y="5"
width="130"
shownitems="3"
editable="false"
defaulttext="choose one...">
<textlistitem datapath="countriesContinents:/item"
text="$path{'text()'}"
value="$path{'@value'}"/>
<method event="onselect">
Debug.write( "onselect called" );
var dp = "countriesContinents:/item[@value='" + this.value
+ "']";
Debug.write( dp );
countries.setDataPath( dp );
</method>
</combobox>
<combobox name="countries"
datapath=""
x="5" y="30"
width="130"
editable="false"
shownitems="3"
defaulttext="choose one..." >
<textlistitem datapath="item" text="$path{'text()'}"
value="$path{'@value'}"/>
</combobox>
</canvas>
-Antun
mallesh
04-08-2004, 02:54 AM
Hi Antun,
The above code working fine.
And also is it possible to populate the combobox by quereing the database and give the datapath to combobox ?
Thanks
mallesh
antun
04-08-2004, 09:40 AM
Yes, that should work.
-Antun
vBulletin® v3.8.4, Copyright ©2000-2012, Jelsoft Enterprises Ltd.