craftleft.gif (3002 bytes)QuickTable
Home | API | Tutorial | Download | Support | Contact topblack.gif (108 bytes)


QuickTable User Cp  |  Register  |  Members  |  Search  |  Help
    |- QuickTable Discussion Forums > Events/Actions Post New Topic   Post A Reply
Commit New Insert Row in Empty Table printer friendly version
next newest post | next oldest post
Author Messages
jeff
Private

Gender: Male
Location:
Registered: Apr 2008
Status: Offline
Posts: 5

Click here to see the profile for jeff Send email to jeff Send private message to jeff Find more posts by jeff Edit or delete this message Reply w/Quote
Posted Tuesday, May 6, 2008 @ 14:11:07  

In the Add/Modify/Delete example (and in general), when trying to add a new row to an empty table, the user can never leave the current row, so the row never gets inserted. I have tried doing a save() in various places, but without knowing in more detail the sequence in which such events as before- and afterRowSelectionChange, before- and afterColumnSelectionChange, before- and afterInsert, cellValueChanged, etc., occur, it is difficult to tell where is the best place to handle committing data in a case like this. What is the best way and where is the best place to handle this? Is calling save() the correct thing to do? How can I ensure that a row is inserted even if the user never navigates away from the row? Is there a way to cause a new row to be inserted immediately as soon as at least one cell of data is entered, then refresh the table in order to capture any database-generated primary key ID for the new row? It seems that calling save() within cellValueChanged() is problematic. Or is there an event fired when a row or table loses focus to another control on the frame and would it be better to cause the insert then? Perhaps you could update the Add/Modify/Delete example to show how to do this?

Thanks,
Jeff

Admin
Board Owner

Gender: Unspecified
Location:
Registered: Jul 2003
Status: Offline
Posts: 9

Click here to see the profile for Admin Send email to Admin Send private message to Admin Find more posts by Admin Edit or delete this message Reply w/Quote
Posted Tuesday, May 6, 2008 @ 20:03:44  

By default data is saved to database when the user moves away from the row. There is an additional option available to update when user moves to a different cell.

DBTable dbTable = new DBTable();
dbTable.setDatabaseUpdateMode(DBTable.UPDATE_DATABASE_ON_ROW_EXIT );

jeff
Private

Gender: Male
Location:
Registered: Apr 2008
Status: Offline
Posts: 5

Click here to see the profile for jeff Send email to jeff Send private message to jeff Find more posts by jeff Edit or delete this message Reply w/Quote
Posted Thursday, May 8, 2008 @ 14:14:43  

Thanks, I am aware of setDatabaseUpdateMode(); however, that's just for updating existing rows. Try this:

1. Starting with empty tables, run AddModifyDeleteTable.
2. Click the "add button" to add a new row.
3. Type in Emp_Number, Emp_Name, Emp_Status.
4. Now try to get that row inserted into the database without adding another new record.

The only way I can get the single new record inserted into an empty table is by adding a second new record, because that's the only way to "move away from the row" just entered in an empty table. But it doesn't make sense to have to enter a second dummy row just to get the first new row inserted.

Even in a table with multiple rows, the idea of requiring a user to move away from a new row in order to get it inserted is also problematic for other reasons. For instance, say a user creates a new row and enters several cells of data without then pressing Tab or Enter to get to another row in the table. Then the user clicks into another control on the frame such a text box or, worse yet, the user quits the application. While the user would expect the data to have been saved, it was in fact never inserted and is lost. In this case, the table should see that it is losing focus and it should commit the insert. I'm just looking for a way to catch this and get the data inserted.

Thanks,
Jeff

Admin
Board Owner

Gender: Unspecified
Location:
Registered: Jul 2003
Status: Offline
Posts: 9

Click here to see the profile for Admin Send email to Admin Send private message to Admin Find more posts by Admin Edit or delete this message Reply w/Quote
Posted Thursday, May 8, 2008 @ 21:43:14  

Sorry I intend to give you the cell exit option. when user moves to a different cell, the save will be invoked.

dbTable.setDatabaseUpdateMode(UPDATE_DATABASE_ON_CELL_EXIT )

You can use various swing focusLost events to and call save() based on your applications needs.

Also you can provide a button called "save" . after user makes changes, they can press thsi button which will call the save() method.

Admin
Board Owner

Gender: Unspecified
Location:
Registered: Jul 2003
Status: Offline
Posts: 9

Click here to see the profile for Admin Send email to Admin Send private message to Admin Find more posts by Admin Edit or delete this message Reply w/Quote
Posted Sunday, May 11, 2008 @ 13:13:14  

We found that UPDATE_DATABASE_ON_CELL_EXIT option is not working properly when you insert a new record and modify data. WE have fixed the issue. Please download the latest version and try again with UPDATE_DATABASE_ON_CELL_EXIT.
Post New Topic   Post A Reply Jump to:
Contact Us | QuickTable - A Java DBGrid | Privacy Policy All times are GMT -5 Hours.
Welcome to QuickTable Forums, Guest!  
Login
Username :
Password :
In order to fully utilize the abilities of this board, you are required to register as a member. Registration is free, and allows you to do lots of things including turning on or off certain features of this board. Register now!
Powered by CuteCast v2.0 BETA 2
Copyright © 2001-2003 ArtsCore Studios