Would it be possible to give forms and/or portals the ‘editable’ property. It would be a simple way of preventing data change on an entire form or in a portal without greying/dimming the data on the form or in the portal.
Thanks
John McCann
Would it be possible to give forms and/or portals the ‘editable’ property. It would be a simple way of preventing data change on an entire form or in a portal without greying/dimming the data on the form or in the portal.
Thanks
John McCann
Is possible, but currently you could use security to prevent edits.
i agree with idoctor
It would be nice, if you could do this by scripting.
Added to planning
Jan,
I am glad this will be added in the future. Securities seems like it works great if you want to restrict a user from editting something. I don’t think you can use it if you want the ability to prevent editting based on something other than the user name or group. For instance if you want to prevent changes to data after a certain date, after a final report is issued, after it has been electronically signed… you need to control it progmatically. Either disabling elements without greying or being able to switch all of the data entry elements to not editible would be of great use.
Thanks
John McCann
Here’s an easy way to set all fields on a form to non editable.
To disable editable:
for ( var i = 0 ; i < elements.length ; i++ )
{
if (elements[i].editable != undefined)
{
elements[i].editable=false
}
}
To enable editable:
for ( var i = 0 ; i < elements.length ; i++ )
{
if (elements[i].editable != undefined)
{
elements[i].editable=true
}
}
to toggle:
for ( var i = 0 ; i < elements.length ; i++ )
{
if (elements[i].editable != undefined)
{
elements[i].editable=!elements[i].editable
}
}
the test for undefined is done because some elements don’t have the editable property and if you don’t do the test it will error. (that’s also the reason why editable is not available on form level)
We renamed the editable property to readOnly..
only Calendar and Combo has a editable property at the moment
With calendar it means that users can’t type the date directly into the textfield but only with the button..
With combo it means that it wil be editable like the designer property for combo (that you can type a value, or only choose from the list)
All field components do have the readOnly property now. Where you can set if the field can change its value. It will use the best possible method for a specific component so that not everything will be dimmed (that happens when you use the enable property)
also portal components and tabpanel do have that property now. For a tabpanel this means that all the tabs it contains will also we readonly.
for globally set a formpanel (and all iets sub panels) to readonly you can now do:
controller.readOnly = true;
You need 2.0RC2 or greater for this.
Perfect! This is just what I needed. It does make more sense to call it readOnly.
Looking over Jan’s code above it finally dawned on me what the square brackets are. The sqare brackets will be very useful for making more of my form specific methods global.
Thanks
John McCann
2.0 rc 2
Remember that you don’t have to only use a index (integer counter) for looking up fields
you can also do this:
for(var i=0;i<numberOfCombos;i++)
{
elements[‘Combo’ + i].editable=!elements[‘Combo’ + i].editable
}
these kind of things should also work if you name all youre combo’s on the form Combo1 to ComboX
i changed tthe readOnly implementation again (it’s not yet perfect in RC2 )
Now if you form is in list or table view it will set the controller itself on readOnly so the table or list is completely not editable. This has only one drawback that you can’t select and copy text from textfields inside the table or listview.
and if you revert from a readOnly state the objects holds there state what they had (so most of the time the state what you have set in the designer)
jcompagner:
elements[‘Combo’ + i].editable=!elements[‘Combo’ + i].editable
This is really one of the COOLEST things! Abstracting objects WITHOUT the use of eval (which is very “expensive” execution wise).
Servoy ROCKS.
Bob Cusick