on 10-15-2009 9:57 PM
I have the requirement to display 2 Dropdown lists where the the selection of the first dropdown list determines the values in the second. The area I am trying to show is the Classification
Data View:
PDFData
+-- Classification (1-1)
+-- ClassNode (0-n)
| +-- ClassLeaf (0-n)
| | +-- value (attribute)
| +-- value (attribute)
| +-- index (attribute)
+-- nodevalue (attribute)
+-- leafvalue (attribute)
Example of data:
Class Node - Valves
- Check Valve
- Oil Valve
- Ball Valve
- Bolts
- Lag Bolt
- Locking Bolt
IThe first Dropdown will have the values of 'Valves' and 'Bolts' and when the user selects one of the values, the contents of the second drop-down will contain tyhe associated values for Valves or Bolts.
So far I displayed the the first Drop-down but in the change event, I am having problems getting the values of the second drop-down to populate correctly. I am having trouble with the formaing of the commands to get the values out of the data tree. I have the addItem method setup and can add the values if I hard code.
I have a routine setup to get the index of the selected value in the first dropdown, so the real question is, how do I get the values for the second drop down? I have looked at examples from the LivLink site but I cannot get them to work.
Glenn
Hi,
I'm not surea about the data structure...Are there two ClassNodes, one for "VALVES" and one for "BOLTS"??
and for scripting it is no good idea if the names of the attributes are value, don't know if this is your naming...
but to access a node of the DATA view -->
//var selection --> you have assigned "VALVES"
var onodeCN = xfa.resolveNodes("xfa.record.Classification.ClassNode[*].value");
// get the node with the valves -->
for (var i = 0; i < onodeCN.length ; i++) {
if ( onodeCN.item(i).value == selection ) {
//get the Leaves of Node VALVES
var onodeVALS = xfa.resolveNodes("xfa.record.Classification.ClassNode[+i+].ClassLeaf[*].value");
for (var j = 0; j < onodeVALS.length ; j++) {
// insert values of Leave to 2nd drop down
XXX.addItem(onodeVALS.item(j).value, onodeVALS.item(j).value);
}
}
}
??works??
norbert
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
The code sample you provided did not quite work as indicated but it gave me enough hints as to get it working. The following is my solution
// get Index of selected record
var nNewSel = this.boundItem(xfa.event.newText);
// Assign ClassNode level
var tempString = "xfa.record.Classification.ClassNode[*]";
// Get object that contains all the children nodes of the Class Node
var onodeCN = xfa.resolveNodes(tempString);
//***** Used for monitoring
//var nItemsLength = onodeCN.length;
//xfa.host.messageBox("Items Length: " + nItemsLength, "debug Script", 3);
// Clear Leaf Drop down
LEAFVALUE.clearItems();
// define the ClassLeaf string
var tempCLString = "xfa.record.Classification.ClassNode[" + nNewSel + "].ClassLeaf[*]";
// get the children nodes for the selected Class Node
var onodeCL = xfa.resolveNodes(tempCLString);
// loop at the Leaf nodes and place the values into the drop down
for (var j = 0; j < onodeCL.length ; j++) {
// insert values of Leaves to 2nd drop down
LEAFVALUE.addItem(onodeCL.item(j).CLASSLEAFVALUE.value, onodeCL.item(j).CLASSLEAFVALUE.value);
}
I also changed the names of the variables so as to avoid confusion.
Thnks for your help.
Glenn
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
78 | |
9 | |
9 | |
7 | |
7 | |
6 | |
6 | |
5 | |
5 | |
4 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.