TOPIC: Default value-ChooseDateControl not bound to field
#848
Default value-ChooseDateControl not bound to field 3 Years, 4 Months ago
I would like to set the default value of a ChooseDateControl that is not bound to any field.
From what I've read, in order to use the Field_/Rule_ the control has to be bound to an empty field in a record.
The ChooseDateControl doesn't seem to have inherited the 'set:' method from anywhere either.

I think I have to create an instance of the ChooseDateControl and set the default value there.

If someone could outline the code to create an instance of ChooseDateControl and set the default value, it would be a great help.
(even if there is an easier way to set the default).

If someone could also give a basic description of how to derive a class from ChooseDateControl which always sets the default value when creating the control, that would be very much appreciated.

Thks,
Chris.
(Hope I got all the right words in the right place:)
 
 
#849
Re:Default value-ChooseDateControl not bound to fi 3 Years, 4 Months ago
Hi Chris,

You may not need to derive a new control since you can set the default value from outside the control.

What is containing the control? Is it in an AccessControl or just a Controller?

In a Controller you can set the value from the New, for example:

Code:

Controller
    {
    New()
        {
        .Vert.ChooseDate.Set(#20070101)
        }
    Controls: (Vert ... ChooseDate ...)
    }



Note: You can have a field in a record without storing it in the database. So if your control is in an AccessControl (or within a RecordControl) you can use Rule_ and Field_ even if it's not actually in the database.

Hope that helps.
 
 
andrew
 
#850
Re:Default value-ChooseDateControl not bound to fi 3 Years, 4 Months ago
That's does exactly what I needed. I wanted to create the control with todays date.

Code:

Controller
{
New()
{
.Vert.ChooseDate.Set(Date().NoTime())
}
Controls: (Vert
    (ChooseDate)
          )
}



Deriving the control was only for educational purposes, I'd like to know how to turn ChooseDate into something like ChooseDateNow so I can replace the above code with something like.

Code:

Controller
{
Controls: (Vert
(ChooseDateNow)
  )
}



I got the answer to my most pressing question so thanks Andrew.

And thanks for Suneido,really enjoying working with it.

Regards,
Chris