challenge: get a list of element names from a form

Find out how to get things done with Servoy. Post how YOU get things done with Servoy

challenge: get a list of element names from a form

Postby Cain » Tue Nov 23, 2004 9:14 pm

I'd like to have a method retrieve a list of the elements on a given form. Ideally, the list would show the text property of the form, but the name property would be acceptable.

Scenario: I have a form with a tabpanel. The tabpanel will show table forms for a number of data elements. I'll have a 'field name' field and a 'field value' field on the main form (above the tabpanel), to be used for filtering the table shown in the tab panel. The 'field name' should show a list of the fields shown in the table.
A list of the elements' 'name' properities would work, but I prefer to leave the 'name' property matching the dataprovider name, and alter the 'text' property instead for a user-friendly name.
Cain
 

Postby pbakker » Tue Nov 23, 2004 9:24 pm

I don't have the specific code right now, but on the form node, there's the ability per form to get the element count. You can then do a loop and do something like:

element[i].getName();

Maybe you can also do getText, dunno about that.

This way you only get the named elements, meaning, the elements that also show in the Servoy Editor.

Hope this gets you going...

Paul
pbakker
 
Posts: 2822
Joined: Wed Oct 01, 2003 8:12 pm
Location: Amsterdam, the Netherlands

Postby Cain » Tue Nov 23, 2004 9:31 pm

I don't have the specific code right now, but on the form node, there's the ability per form to get the element count.


As luck would have it, that's the code I can't find. :-)
Cain
 

Postby pbakker » Tue Nov 23, 2004 10:00 pm

var elementsArray = new Array();
for ( var j = 0 ; j < forms.XXX.elements.length ; j++ )
{
elementsArray[j] = forms.XXX.elements[j].element_name.getName();
}
pbakker
 
Posts: 2822
Joined: Wed Oct 01, 2003 8:12 pm
Location: Amsterdam, the Netherlands

Postby Cain » Wed Nov 24, 2004 1:42 am

Awesome! :-)

Minor change: remove .element_name from the next to last line.
Cain
 


Return to How To

Who is online

Users browsing this forum: No registered users and 5 guests