[Gambas-user] DataView Help
T Lee Davidson
t.lee.davidson at gmail.com
Fri Jul 7 21:46:17 CEST 2023
On 7/7/23 11:26, Gianluigi wrote:
> Hi Benoit,
>
> in this (*) your response to Hans, to have more control over the data, you suggest the use of DataView and custom buttons.
>
> (*) https://lists.gambas-basic.org/pipermail/user/2022-August/076746.html
>
> For the past few days I have been trying to figure out how to insert new data (Minnie) into the project table that you can
> download at this link:
>
> https://paste.c-net.org/TrippPaolo
>
> (It weighs too much because of the presence of images).
>
> Can you kindly put me on the right track?
>
> I thank you for your attention and sorry for my ignorance
>
> Regards
>
> Gianluigi
Well I'm not Benoît, obviously, but here are my observations from playing around with it.
First, I think DataView.Create and DataSource.Create should be separated into distinct event handlers as in the code below,
because one is for creating a new record and the other is for saving the record.
Second, I suspect the difficulty you are having is due to bugs in the Controls.
The only way I found to get the DataView to add a new blank record, is to set it Editable prior to calling the Create method.
The DataControls are then blanked out, but the DataView still does not display the new blank record.
The saving of only a partial record appears to be caused by the behavior of the date chooser in the DataControl for the
'birth_date' field. When that dialog is closed (either by pressing ESC or by clicking on the field), the record is automatically
saved. Fields that have not yet been populated with data are set to null values in the database.
The last record in the DataView is indeed duplicated in the display, but not in the database. The newly created record is
actually inserted into the database but not displayed.
DataView.Update appears to do nothing.
[code]
Public Sub btnAdd_Click()
'' When I try to enter the data the last record doubles in the DataView
'' but actually a partial record is added.
'' Disaster :-(
DataView1.Editable = True
DataView1.Create
DataView1.Editable = False
End
Public Sub btnSave_Click()
DataSource1.Create
DataView1.Update ' Appears to do nothing
End
[/code]
--
Lee
More information about the User
mailing list