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 > Column Post New Topic   Post A Reply
Refreshing QuickTable without changing columns and scrollbar... printer friendly version
next newest post | next oldest post
Author Messages
Dennis Westra
Unregistered
Edit or delete this message Reply w/Quote
Posted Wednesday, July 11, 2007 @ 07:13:22  

Hi,

Im currently writing an application which uses QuickTable to display data from a database.
The application gives the users the ability to see data from the database and sort or filter it.
When the user sorts the data, the application fires a new query and then display the new data.

What i want to achieve is that the user refreshes the data in the grid (by sorting) and all the columns stay the same -> Same width, titles, ordering and i also want all the scrollbars to remain at the same position.
With my current code this does not happen.

Code:

import java.awt.BorderLayout;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.sql.Connection;

import javax.swing.JButton;
import javax.swing.JFrame;

import com.sun.rowset.CachedRowSetImpl;

import quick.dbtable.Column;
import quick.dbtable.DBTable;

public class Apl {

/**
* @param args
*/
public static void main(String[] args) {
final Connection connection;

JFrame frame = new JFrame();
frame.setSize(320, 240);

final DBTable table = new DBTable();

String connectionString;
String server = "localhost";
String database = "tsf_sf";
String username = "sa";
String password = "tsf01d";
String url = "jdbc:jtds:sqlserver://";
String driver = "net.sourceforge.jtds.jdbc.Driver";

try {
Class.forName(driver);
connectionString = url + server + ";DatabaseName=" + database;
connection = java.sql.DriverManager.getConnection(
connectionString, username, password);

CachedRowSetImpl rowSet;
rowSet = new CachedRowSetImpl();
rowSet.setCommand("select project_id, project_vrs_id, tab_id, col_id from col");
rowSet.execute(connection);
table.refresh(rowSet.getOriginal());

Column projectId = table.getColumn(0);
projectId.setHeaderValue("Project");
Column projectVrsId = table.getColumn(1);
projectVrsId.setHeaderValue("Project version");
Column tabId = table.getColumn(2);
tabId.setHeaderValue("Table");
Column colId = table.getColumn(3);
colId.setHeaderValue("Column");

JButton button = new JButton("Refresh");
button.addActionListener(new ActionListener(){

public void actionPerformed(ActionEvent e) {
try {
table.useOldColumnProperties(true);
CachedRowSetImpl rowSet = new CachedRowSetImpl();
rowSet.setCommand("select project_id, project_vrs_id, tab_id, col_id from col");
rowSet.execute(connection);
table.refresh(rowSet.getOriginal());
} catch (Exception exception) {
exception.printStackTrace();
}
}

});

frame.setLayout(new BorderLayout());
frame.add(table, BorderLayout.CENTER);
frame.add(button, BorderLayout.SOUTH);
} catch (Exception exception) {
exception.printStackTrace();
}

frame.setVisible(true);
}
}

This is an example I made to demonstrate my issue. This application makes a frame with a button and a QuickTable.
The quicktable displays data from a database. When you press the button, the data gets refreshed. When the data gets refreshed the columns change back to their original form and the scrollbars go to the upper left of the screen. I hope this makes my problem clear.

Is there an option to leave all the columns the way they are and to leave the scrollbars at their current positions?
If so, how?

Dennis Westra
Unregistered
Edit or delete this message Reply w/Quote
Posted Wednesday, July 11, 2007 @ 08:42:13  

I forgot to add that it seems like keyboard navigation isn't working properly.
When i use the arrow keys to scroll left and right, the navigation stops whenever i come across an invisible column.
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, July 11, 2007 @ 19:54:38  

have you tried to use table.useOldColumnProperties(true) before refresh ? refer api

If they sort by clicking column headers, the columns will remain width/title etc will remian the same.

Dennis Westra
Unregistered
Edit or delete this message Reply w/Quote
Posted Thursday, July 12, 2007 @ 01:37:24  

In my actionPerformed code I execute this code:
Code:

try {
table.useOldColumnProperties(true);
CachedRowSetImpl rowSet = new CachedRowSetImpl();
rowSet.setCommand("select project_id, project_vrs_id, tab_id, col_id from col");
rowSet.execute(connection);
table.refresh(rowSet.getOriginal());
} catch (Exception exception) {
exception.printStackTrace();
}

As you can see i do use table.useOldColumnProperties(true) before i do refresh.
As for the sorting, i do sort by clicking on the column headers, but i have written my own code for it, so my program fires a new query. This causes the table to be refreshed and everything goes back to its original position. Thats not what i want.

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, July 16, 2007 @ 11:30:54  

we will look into this & get back to you. We might need some more time to investigate this.
Dennis Westra
Unregistered
Edit or delete this message Reply w/Quote
Posted Monday, July 23, 2007 @ 04:25:27  

Hello,

do you have any indication when this problem will be fixed?

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, July 23, 2007 @ 19:16:14  

Please download the latest version, this problem is fixed.
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