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
Clearing a cell? printer friendly version
next newest post | next oldest post
Author Messages

Unregistered
Edit or delete this message Reply w/Quote
Posted Friday, April 23, 2004 @ 20:42:36  

Ben,

I want to be able to set a cell to blank on a column that has a bound sql. I've tried to do the following:

if (e.getKeyCode() == KeyEvent.VK_F4) {
dbt1.setValueAt(new String(),
dbt1.getEditingRow(), dbt1.getEditingColumn());

}

This doesn't work unless I immediately hit the Escape key after I hit the f4 key. The sql statment's results do not contain a blank entry and once set I have no other way of unsetting it. Is there a better way?

--------------------

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, April 26, 2004 @ 19:43:17  

when you use setBoundSql, an empty cell is not added to the combobox to set the cell value as empty. Please use the following workaround, which will add the empty cell, this will allow you set the cell value empty.

public void setBoundSql(int col, String boundSql)
{
Statement stmt = null;
ResultSet rs = null;

stmt = dbTable.getConnection().createStatement();
rs = stmt.executeQuery(boundSql);

Vector sortVector = new Vector();
Hashtable hash = new Hashtable();

while(rs.next())
{
String key = rs.getString(1);
hash.put(key, rs.getString(2));
}

dbTable.setCellComponent(dbTable.getColumn(col), Column.COMBOBOX_CELL, hash, true);

rs.close();
stmt.close();

}


Unregistered
Edit or delete this message Reply w/Quote
Posted Wednesday, April 28, 2004 @ 22:16:23  

Ben,

I tried this as it was posted and it the set doesn't contain a blank record (I added one) but additionally, the llist is no longer in alphabetical order. How do you implement the actual SetBoundSQL to keep it in order?

--------------------

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, April 28, 2004 @ 22:24:42  

Use the setCellComponent method which accepts a sortorder vector

Unregistered
Edit or delete this message Reply w/Quote
Posted Thursday, April 29, 2004 @ 20:52:50  

Ben,

I played around with this method. I don't understand what the object array needs. There is no javadoc that expains how this works. What do I need to put into that parameter to get the sorting correct?

--------------------

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, May 3, 2004 @ 10:48:35  

I will update the api documentation about how to use keysSortOrder array.

I have fixed the code to use this sort array below.

public void setBoundSql(int col, String boundSql)
{
Statement stmt = null;
ResultSet rs = null;

stmt = dbTable.getConnection().createStatement();
rs = stmt.executeQuery(boundSql);

Vector sortVector = new Vector();
Hashtable hash = new Hashtable();

while(rs.next())
{
String key = rs.getString(1);
sortVector.addElement(key);
hash.put(key, rs.getString(2));
}

dbTable.setCellComponent(dbTable.getColumn(col), Column.COMBOBOX_CELL, hash, sortVector.toArray(), true);

rs.close();
stmt.close();

}

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