- Mark as New
- Follow
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report
You can create a dataset with code, which might be the best approach for you. So in the forms initialize event you could have some code like;
var namesXML = <Root>
<Row>
<Name>Lederarmschienen</Name>
<Ko>0</Ko>
<Br>0</Br>
<Ru>0</Ru>
<Ba>0</Ba>
<LA>1</LA>
<RA>1</RA>
<LB>0</LB>
<RB>0</RB>
<gRS>0.1</gRS>
<gBE>0.1</gBE>
<Gew>1</Gew>
<Preis>15</Preis>
<Slot>Arm</Slot>
<Typ>Leder</Typ>
</Row>
<Row>
<Name>Plattenarme</Name>
<Ko>0</Ko>
<Br>0</Br>
<Ru>0</Ru>
<Ba>0</Ba>
<LA>5</LA>
<RA>5</RA>
<LB>0</LB>
<RB>0</RB>
<gRS>0.5</gRS>
<gBE>0.5</gBE>
<Gew>3</Gew>
<Preis>200</Preis>
<Slot>Arm</Slot>
<Typ>Platte</Typ>
</Row>
</Root>;
var names = xfa.datasets.createNode("dataGroup", "Root");
names.loadXML(namesXML.toXMLString());
xfa.datasets.nodes.append(names);
I'm using an E4X literal here to make it easier to cut and paste. Also note that the top element in the XML will be replaced by the name in the second parameter of the createNode method (so easiest thing is to keep them the same)
Then you can reference this in code, so maybe in the exit event of the name field (TextField1 in the code below) you could have the following code to populate other fields;
var row = xfa.datasets.Root.resolveNode("Row.(Name.value=='" + TextField1.rawValue + "')");
if (row !== null)
{
Ko.rawValue = row.Ko.value;
Preis.rawValue = row.Preis.value;
Slot.rawValue = row.Slot.value;
Typ.rawValue = row.Typ.value;
}
I personally prefer this approach but since I started using E4X I should probably point out that we could also use E4X to process the XML, so this does the same thing.
var row = namesXML.Row.(Name==this.rawValue);
if (row.length())
{
Ko.rawValue = row.Ko.toString();
Preis.rawValue = row.Preis.toString();
Slot.rawValue = row.Slot.toString();
Typ.rawValue = row.Typ.toString();
}
Here is a link to the form I used to check my code, https://acrobat.com/#d=yCY7Hi15yg7yVWFbslkXmw
Hope it helps
Bruce
Views
Replies
Total Likes