Simplicty and flexibility!


New Sample - How to manipulate records in a sub form using DatePicker()

Started by DataEase
You will need to Sign In to be able to comment on the Blog!

New Sample - How to manipulate records in a sub form using DatePicker()

Download Sample

We got a challenge under the AskUS "Program" so we jumped on it. It was quite nifty actually, and since it gave us an "awakening" we thought we would share it.

In DE8 we are really braking up the water thight walls between data and programming. You can use ExecDQL generated in Runtime to manipulate data/forms/objects etc. 

In DE traditionally it has been very little you could do in runtime with the app, so we have always concentrated on trying to do it in field/data logic.

When we got this "quest" this is where we started to. How to make sure that we manipulate the right record. Problem though was that in a subform you can scroll up and down, so records change position, and when you have 10 rows and an emty form you have 10 "new" records.

All the logic is related to existing records if you want to use keys, so how do we do it?

We don't do it at all!

The best way of doing this is by building our own "control". in DE8 you can manipulate objects by number. i SetValue("DateField") will set the value in the first DateField in the

form. In subforms DE clones the initial objects so all objects have the same name in each record, to work around this we have added a number option to the

Set functions i.e. SetValue("DateField#10",datepicker()) will set the date in the 10th datefield on the form.

One important thing to realise when manipulating objects is that they are only hosts for data, they are not linked to the data in records. The same way a Form is the same for

all records in the the table, the 10 subform records are host for any number of subrecords, so to link or DatePicker logic to the record is no good.

But do we have to bother with it at all? No. We do all this subform stuff because we want the data to be stored in flat structure, but the forms don't have to reflect this. This is 

actually a perfect occasion to show how Form logic can be forged to work with data logic.

Above I have simply made one button for each row in the Subform, made the subform transparent and put the buttons under the subform so they look like they are part of

the subform. Each button manipulate a DataField object from 1 to 10. ex. 

SetValue("DateField#5",DatePicker()) as an action on the button.

The brilliance of this is that it will always manipulate the field next to it, so when you scroll up and down in the subform it will still work.

COOL!

You an of course use all kinds of Set functions this way. 

SetColor(), SetState(),SetFocus(), SetColor(), SetLabelText etc..

Enjoy!



Written by DataEase 24/07/13 at 13:52:18 Dataease [{8}]FIVE