TOPIC: Field classes modifications
#219
Field classes modifications 4 Years, 3 Months ago
Hello,

Many times I use fields to only display information from a table.The field definition usually derive from the field of the original table and the Control: alone is redefined. Then just to add a readonly: true I have to write the full Control definition once more. More than that if I change the original field definition, I should check which all field definitions derive from it and then modify them also. Would it be better if readonly is implemented by Field class rather than the different controls? May be that would help prevent some controls not implementing readonly. Not only readonly, but I would suggest width and set to be promoted as member of Field class. In short I am suggeting that we should be able to use -

Code:


Field_xxx

Field_string
{
Prompt: "xxx"
Control: (ChooseMany ...)
Width: 14
Readonly: false
Set: "Default Value"
}


so that I can derive from it

Code:


Field_yyy

Field_xxx
{
Readonly:true
}



ajith

Post edited by: ajith, at: 2006/05/04 17:13
 
 
#224
Re:Field classes modifications 4 Years, 3 Months ago
Hi Ajith,

That is a good suggestion, unfortunately it would not be too easy to do. Another approach to set the fields readonly is to define a rule for the field name with a suffix of "__protect". Return true to protect the field, or false not to. This will only work inside an AccessControl, BrowseControl, or ExplorerListViewControl at the moment.
 
 
Jeff Ferguson
Suneido Software
 
#225
Re:Field classes modifications 4 Years, 3 Months ago
Hello Jeff,
Now that you have referred to rules - I have another doubt (probably too silly). Why should the rules that determine the default values / calculations for a field be another record? QueryFormat supports both static values and methods for its different members. Why cant Field classes do it the same way? Example -
Code:


Field_string
{
Prompt: "vvv"
Control: #(ChooseMany ...)
Rule()
{
my code
}
}


or better still would be that set and other members should accept either static or methods that return a standard value
ajith
 
 
#227
Re:Field classes modifications 4 Years, 3 Months ago
Hi Ajith,

I like that idea. It would be nice to have everything related to a field defined centrally in the datadict record. It could probably be done, but again, it is not going to be an easy task, and would have to remain compatible with the separate Rule function definitions.
 
 
Jeff Ferguson
Suneido Software
 
#228
Re:Field classes modifications 4 Years, 3 Months ago
Hello,
Good to hear that you like the idea. We will wait and see what Andrew has to say.
ajith

Post edited by: ajith, at: 2006/05/05 16:09
 
 
#250
Re:Field classes modifications 4 Years, 2 Months ago
Hi Andrew,
What do u think about it?
ajith
 
 
#251
Re:Field classes modifications 4 Years, 2 Months ago
I agree that it is awkward to have to repeat the control just to add things like readonly. Your suggestion to be able to put readonly: on the Field_ definition seems reasonable and probably would be easy to implement.

I agree it would be nice to have everything related to a field in one place. However, rules are a little harder because they are called from the exe, whereas Field_ definitions are just part of stdlib. (The exe currently knows nothing about Field_ definitions.)

Thanks for the suggestions!
 
 
andrew