Enumerate all form elements?

Hi Folks - Is there a way to enumerate every element on all forms? I’d like the ability to step through all forms in the solution, check the element type and populate a table with the elements name, type, label text etc.

I suspect if I was running a Servoy repository I could query the tables there - but for the moment I’m using a workspace only. Is there a way to do this in code?

Hi Ian,

as far as I know there’s no way to enumerate your elements.
But if it’s really just the info you want, I would say: use the solutionmodel to automate this, although getting a ‘name’ for the element won’t be available…

Good luck!

mboegem:
Hi Ian,

as far as I know there’s no way to enumerate your elements.
But if it’s really just the info you want, I would say: use the solutionmodel to automate this, although getting a ‘name’ for the element won’t be available…

Good luck!

Thanks Marc

Looks like you’re right - I cant get all of the data I was hoping for. I’ve passed the topic over to McCourt to explore and I think he’s posting on another thread to see if there is some examples of using the form element index to loop through them and grab content for further SQL work.

The following code will only work if you name every element for each form throughout your solution.
I do as a matter of habit since I know at some point I will want an element to appear or disappear. :wink:
but_xxx - buttons
lbl_xxx - labels
fld_xxx - fields
tab_xxx - tabpanels
tabs_xxx - tabs on tabpanels
etc.
By categorizing the elements through the naming convention, I can then manipulate the correct properties and related values for each type of element.

It would be nice if Servoy added a “type” property to each element so that you could read the type of element (label, button, field, etc.) directly from the element. :)

var allForms = forms.allnames
for ( var i=0; i< allForms.length; i++)
{
	var allElements = forms[allForms[i]].elements.allnames
	for(var j=0;j<allElements.length;j++)
	{
		//forms[allForms[i]].elements[allElements[j]].someProperty = someValue;
	}
}

Every element allready has a function called getElementType().

Paul

rvpm:
The following code will only work if you name every element for each form throughout your solution.
I do as a matter of habit since I know at some point I will want an element to appear or disappear. :wink:
but_xxx - buttons
lbl_xxx - labels
fld_xxx - fields
tab_xxx - tabpanels
tabs_xxx - tabs on tabpanels
etc.
By categorizing the elements through the naming convention, I can then manipulate the correct properties and related values for each type of element.

It would be nice if Servoy added a “type” property to each element so that you could read the type of element (label, button, field, etc.) directly from the element. :)

var allForms = forms.allnames

for ( var i=0; i< allForms.length; i++)
{
var allElements = forms[allForms[i]].elements.allnames
for(var j=0;j<allElements.length;j++)
{
//forms[allForms[i]].elements[allElements[j]].someProperty = someValue;
}
}

i wouldnt do this all the time on a big solution
this creates ALL forms at runtime and will destroy it again.

its better to go through the solution model for this

in tano you have solutionModel.getForms() (but getting forms.allnames is fine)

and then in tano you can do form.getComponents() to get all of them
and in 4.1 you can do getFields()/getButtons() and so on

I definitely appreciate all of the new capabilities in Tano and cannot wait to use them. :D
The code as presented was taken from a solution originally developed on a 3.1.3 version of Servoy.