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 > General QuickTable Support/Help Post New Topic   Post A Reply
value od a cell can be modified when inserting a record but ... printer friendly version
next newest post | next oldest post
Author Messages
infow
Unregistered
Edit or delete this message Reply w/Quote
Posted Sunday, October 30, 2005 @ 07:25:56  

hi,
when the user insert a new record in the table, he can modify a cell (before insert into database).
But this cell must no be modified when the record exist in the table (update database)

i know there is setReadOnly(true) but it's for all the column...
how can i know if the cell is in a new record (state before insert) or if the record is still in the database (state update) ?

thank for your help and have a nice day

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 Monday, October 31, 2005 @ 10:47:40  

In addition to column based readonly and whole table readonly, you can also control the readonly based on cells. You need to create a CellPropertiesModel which implements the method "public int getCellEditable(int row,int col)" and then allow the user to edit only if the row is a newly inserted row.

To identify whether a row is currently inserted, create an instance of DatabaseChangeListener which implements the method "public boolean onNewButtonClick()". In future, we will provide a better way to identify whether a row is currently in the process of insertion.

Code:

public boolean onNewButtonClick()
{
insertRow = dbTable.getRowCount();

//let quicktable do the default insert
return true;
}

public int getCellEditable(int row,int col)
{
if( row == insertRow )
return 1;
else
return 0; //or even -1, read API

}


infow
Unregistered
Edit or delete this message Reply w/Quote
Posted Friday, November 11, 2005 @ 06:34:34  

Thanks for your help.
It's working but when the user insert more than one line without a commit then your function doesn't work
(insertRow) because not only the last line is in insert mode but more than one ...

How can i fix this please ?

thank and have a nice day

infow
Unregistered
Edit or delete this message Reply w/Quote
Posted Friday, November 11, 2005 @ 11:56:38  

i found a solution.
i associate a boolean[] to the table who give me the true if it's in insert mode or not ...
thank for your help
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, November 20, 2005 @ 06:23:58  

A new method "public boolean isInsertingRow(int row)" is added to help with this problem.

From the time when the row was inserted into the table and until the inserted row was added to the database, this method will return true for that row. This will be useful if you want to allow the user to edit newly inserted rows only using CellPropertiesModel.getCellEditable(int row, int col)

infow
Unregistered
Edit or delete this message Reply w/Quote
Posted Thursday, December 8, 2005 @ 09:02:57  

thank for your help.

there is only one problem. The method is returning FALSE when i leave the line and reenter the line.
But the line is not yet inserted into the table because i haven't make a commit !
and your function says that it's not in insert mode but it is !

i'm using this one for the jtable :
autoCommit = false;
getConnection().setAutoCommit(false);

thank for your help and have a nice day.

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, December 8, 2005 @ 09:59:35  

This method will work only if quicktable handles the insert for you. If you are handling the database changes yourself using commit, then this method will not be helpful.
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