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 > JDBC/Database Issues Post New Topic   Post A Reply
Primary unique key printer friendly version
next newest post | next oldest post
Author Messages
Henrik V Eriksson
Unregistered
Edit or delete this message Reply w/Quote
Posted Wednesday, May 4, 2005 @ 20:04:49  

I'm more and more impressed by the features of QT...!

I've not been able to figure out how QT handles primary unique key updates.
Can you point out where I'll be able to find some samples and/or documentation covering this topic?

I use the UPDATE_DATABASE_ON_ROW_EXIT model and would like to implement the following:

// column(0) is primary unique key
getCellEditable(int row, int col) { ...

if (row-exit--has-not-occurred-yet) cell return 1; // All fields open

if (col == 0) return 0; // Primary key, NOT editable

return 1; // All other fields are editable
}

Also, I need to identify a cell as cell in a new row (i.e. a row that hasn't been inserted into the DB yet).

Something like:
if (dBTable1.getRow(n).isNewRow())

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 Wednesday, May 4, 2005 @ 20:31:02  

1) In order to update primary keys, please refer the api help for the method

addUpdateSql(java.lang.String updateStatement, java.lang.String columnPointer, int[] primaryColumns)

Once you pass the primaryColumns column pointer array, quicktable will automatically take care of updates of primary columns.

example if emp no is primary column and if the current emp no=1 and user updates that to 2, then update statement will be executed with update .. empno=2 where empno=1

2) It looks like you don't want to allow the user to update the primary columns using the getCellEditable() method. You can acheive that by calling setEditable(false) on that column.

3) unfortunately currently there is no method like isNewRow(). But it can be acheived using the onNewButtonClick() & afterInsert() methods in DatabaseChangeListener.

Code:

DatabaseChangeListener.
{
Set newRows = new HashSet();

public boolean onNewButtonClick()
{
//since rows are added at the end
//the new row index will be the max row
newRows.add(new Integer(dbTable.getRowCount()));
return true;
}

public void afterInsert(int row){
newRows.remove(new Integer(row));
}

public boolean isNewRow(int row)
{
newRows.contains(new Integer(row));
}
}

Please have a look at CustomerOrderDemo sample, that will give you an idea about most of the quicktable classes.

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