dorizo / jquery-option-tree

Automatically exported from code.google.com/p/jquery-option-tree
0 stars 0 forks source link

Preselect is not working #1

Closed GoogleCodeExporter closed 8 years ago

GoogleCodeExporter commented 8 years ago
What steps will reproduce the problem?
1. Using optionTree to cascade country/state
2. Have var loc_tree with proper structure.  Works just fine for initial 
entry.
var loc_tree = {
    "Canada":"2:CAN",
    "Canada ==>":{
        "Nova Scotia":"75:NS",
        "Quebec":"74:QC"},
    "Mexico":"3:MEX",
    "United States":"1:US",
    "United States ==>":{
        "Alabama":"14:AL",
        "Alaska":"13:AK"}
    };

3. For edit, I have var config with preselect set to existing state, 
like "13:AK".
4. It doesn't seem to have an effect.  Still only displays countries.

What is the expected output? What do you see instead?
I expected it to have "United States ==>" selected for country 
and "Alaska" selected for state

What version of the product are you using? On what operating system?
I just downloaded it yesterday, so I have the latest version, 1.0.1
I'm running on Windows XP and Apache.

Please provide any additional information below.
It isn't clear how to use preselect.  Do I specify the cascading 
elements, "United States ==>" + "Alaska" or what?

Original issue reported on code.google.com by psyclo1...@gmail.com on 14 Jul 2009 at 2:30

GoogleCodeExporter commented 8 years ago
[deleted comment]
GoogleCodeExporter commented 8 years ago
OK, I figured out that I had misunderstood the "preselect" option.  I needed to 
specify the form field and value, like: LOC_ID:"13:AK"
Well, I did this, but it doesn't quite work.
If I set preselect to Alaska, I get the initial "Choose..." select with the 
list of 
countries.  Only if I select "United States ==>" do I get Alaska preselected.
I need for it to start off with United States *and* Alaska selected when I 
first 
display the form.

Original comment by psyclo1...@gmail.com on 14 Jul 2009 at 6:02

GoogleCodeExporter commented 8 years ago
[deleted comment]
GoogleCodeExporter commented 8 years ago
This behaviour was by design - as you could see on the demo page, option values 
in
the tree are not unique, for example you could have an option with the same 
value in
each tree "branch" - so the plugin wouldn't know which option to choose from.

However, now I can see that the use case you presented is pretty common  and 
I'll try
to find a way to achieve that behaviour. Of course, any patches are more than 
welcome.

Original comment by kkotowicz on 6 Aug 2009 at 7:16

GoogleCodeExporter commented 8 years ago
It is now (as of version 1.2) possible to pass an array of values for the 
preselect option for a given field, so in your case it would be:

{"LOC_ID": ["United States","Alaska"]} 

and it should work OOTB.

Original comment by kkotowicz on 6 Oct 2010 at 8:54