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
combobox editor for foreign key printer friendly version
next newest post | next oldest post
Author Messages
bromley{@}htc.net
Unregistered
Edit or delete this message Reply w/Quote
Posted Wednesday, December 31, 1969 @ 23:59:59  

Ben,

I'd like to use a function similar to a foreign key
for several of my columns. I've like to be able to
"display" one value on the table but when selected
with a combo box, actually insert that values key
into the database (not the displayed value). Does
this make sense? Is there a way to do it or will I
need to play with some Cell editor/render
combinations myself? -- Steve
admin{@}quicktable.org
Unregistered
Edit or delete this message Reply w/Quote
Posted Wednesday, December 31, 1969 @ 23:59:59  

Steve,

There are two ways to do this
1) Using setBoundSql() method in column
Lets say your query is select emp_name , dept_name...
and dept_name is foreign key, then
dBTable1.getColumn(1).setBoundSql("select distinct dept_name from dept..")

2) Using setCellComponent() method in DBTable
Lets say your query is select emp_name , dept_no...
and dept_no is foreign key, also lets say you don't want to display dept_no in table, instead you would like to show dept_name, but whenever there is a update, you want to update the dept_no,then

//create quicktable with query select emp_name,dept_no..

// execute a query separately through jdbc to your database with "select distinct dept_no , dept_name from dept"


//from the resultset create a hashtable
Hashtable h = new Hashtable();

while(rs.next())
{
h.put(rs.getString(1),rs.getString(2));
}
Column c = dBTable1.getColumn(2);
dBTable1.setCellComponent(c,Column.COMBOBOX_CELL,h);

The second feature(setCellComponent()) is available only in new version of quicktable, please download again.

Let me know whether that solves your problem.

Thanks
Ben

Ben,

I'd like to use a function similar to a foreign key
for several of my columns. I've like to be able to
"display" one value on the table but when selected
with a combo box, actually insert that values key
into the database (not the displayed value). Does
this make sense? Is there a way to do it or will I
need to play with some Cell editor/render
combinations myself? -- Steve



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