on 06-19-2008 4:03 PM
dear all,
how can I access the value of a field of a table row in javascript?
for example: table F4_CITY with Colums COUNTRY, PLZ and CITY
In the data-view it's
F4_CITY
--DATA
-
COUNTRY
-
PLZ
-
CITY
how to loop over this table and access the fiel values??
thanks for your help!
norbert
Exactly Juergen, but I don't know why my script is not working.
in the abap world my table F4_COUNTRY has 2 colums, COUNTRY, COUNTRYTXT (DE, Deutschland...).
in the abap world my table F4_CITY has 3 colums, COUNTRY, PSTLZ, CITY. (DE, 10123, Mannheim...).
In the form there is DATA as repeating node added (F4_COUNTRY - DATA - COUNTRY, COUNTRYTXT) same for F4_CITY.
And I've three fields on my form (COUNTRY, PSTLZ, CITY). COUNTRY as DDLB, PSTLZ as DDLB, CITY as textfield.
I want to realize following scenario:
if the value of the field (DDLB) COUNTRY changes, the values of the field PSTLZ (DDLB) and CITY have to be cleared. The DDLB of PSTLZ has to change whenever a new country is selected in the COUNTRY DDLB. Whenever a new value in the PSTLZ DDLB is selected, the CITY field (no input) has to be filled automatically.
I got two major problems:
the first DDLB I've bound to a table in the form (DDLB COUNTRY, F4_COUNTRY.DATA[].COUNTRY as key, F4_COUNTRY.DATA[].COUNTRY as text).
Event "change" for the Country DDLB:
I want to get the new selected value but xfa.event.newtext gives only the text but not the key back to me.
thats problem one! the old value I can get like this COUNTRY.rawValue
var newValue = xfa.event.newText; //wrong, because not the key!!
//then I can compare the value
if (newValue != COUNTRY.rawValue) {
PSTLZ.rawValue = null;
CITY.rawValue = null;
PSTLZ.clearItems();
// now i should count, how many entries i have in the F4_CITY table, dont know how!!var citynodes = xfa.resolveNodes("F4_CITY.DATA");
var cityLength = citynodes.length;
for (var i=0; i < cityLength; i++) { //loop over the table with the Citys and PSTLZs
if (F4_CITY.DATA<i>.COUNTRY == newValue) { //wrong again!!!
PSTLZ.addItem(F4_CITY.DATA<i>.CITY , F4_CITY.DATA<i>.PSTLZ);
} //if
} //for
I think, I missunderstand the "nodes" within tables, wht's wrong here??
F4_COUNTRY is parent of DATA and occurs only once.
DATA is child of F4_COUNTRY and is repeated (depends on entries)
COUNTRY is child of DATA and exists once for each "data-item"
COUNTRYTXT is child of DATA and exists once for each "data-item"
so what's wrong here??
please help!
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Norbert,
okay.
Let's start with problem #1.
There is a method called boundItem() use something like
this.boundItem(xfa.event.newText) to get the key.
problem #2
Look at my blog:
/people/juergen.hauser2/blog/2007/09/03/accessing-data-nodes-in-sap-interactive-forms
You need a resolveNodes like
xfa.resolveNodes("xfa.datasets.data.XXX.F4_CITY.DATA[*]")
XXX is the root node of your data structure.
Regards,
Juergen
Hi norbert,
Try this...
var tempNodes = F4_CITY.DATA.nodes;
var tempNodesLength = tempNodes.length;
var tempCity;
for (var i = 1; i < tempNodesLength; i++) {
tempCity = xfa.resolveNode("F4_CITY.DATA.Row1["+ (i-1) +"].CITY").rawValue;
}
Note that in the above table, "Row1*" is being repeated within the table... You may have to tweak the code according to your structure... Its better to look at the structure in the "Hierarchy" tab to figure this out...
hope this helps,
harman
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Thanks, I'll try it, I think data is the repeated part...
I got the following error message :
xfa.resolveNode("F4_CITY.DATA.["+ (i-1) +"].CITY") has no properties
when I click on field of the table in the livecycledesigner i got the following data binding:
$record.F4_CITY.DATA[*].COUNTRY
that's why i thought, that F4_CITY is the table definition
DATA the repeating element
and COUNTRY an attribut of the repeating element
my Coding looks like this:
var tempNodes = F4_CITY.DATA.nodes;
var tempNodesLength = tempNodes.length;
var tempCity;
for (var i = 1; i < tempNodesLength; i++) {
tempCity = xfa.resolveNode("F4_CITY.DATA.["+ (i-1) +"].CITY").rawValue;
xfa.host.messageBox("test: " + tempCity);
}
any idea??
br
norbert
Edited by: Norbert Prager on Jun 20, 2008 7:57 AM
Hi Norbert,
You have to make a destinction between accessing data nodes and fields of the form template.
Please read my blog:
/people/juergen.hauser2/blog/2007/09/03/accessing-data-nodes-in-sap-interactive-forms
It explains how to access data nodes. My understanding is that you want to do this.
Regards,
Juergen
User | Count |
---|---|
84 | |
10 | |
10 | |
10 | |
7 | |
6 | |
6 | |
5 | |
4 | |
4 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.