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
I´m searching for master-detail form sample printer friendly version
next newest post | next oldest post
Author Messages
vmejiaec
Unregistered
Edit or delete this message Reply w/Quote
Posted Tuesday, December 26, 2006 @ 10:54:30  

:) Hi, I´m searching for master-detail from sample with QuickTable. I´m working in my own versión of master-detail form, but I´m grateful if someone can help me and send me a sample.

Thanks.

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 Tuesday, December 26, 2006 @ 14:50:59  

Please read the following thread first

http://quicktable.org/discussion/cutecast/cutecast.pl?forum=3&thread=86

If you would like to use two quicktables, one with master data and the second with detail data. Then you can use the following code

Code:

import javax.swing.*;
import quick.dbtable.*;
import java.sql.*;

public class QuickTableFrame extends JFrame
{
public QuickTableFrame()
{
//set Frame properties
setSize(300,200);
setVisible(true);

//create master & detail tables
quick.dbtable.DBTable masterTable = new quick.dbtable.DBTable();
quick.dbtable.DBTable detailTable = new quick.dbtable.DBTable();

//add to frame
getContentPane().add(masterTable, BorderLayout.CENTER);
getContentPane().add(detailTable, BorderLayout.SOUTH);

//set the database driver to be used, we are using jdbc-odbc driver
masterTable.setDatabaseDriver("sun.jdbc.odbc.JdbcOdbcDriver");

/*
set the jdbc url,"quicktabledemo" is the data source we have created
for the database
*/
masterTable.setJdbcUrl("jdbc:odbc:quicktabledemo");

// set the select statement which should be used by the table
masterTable.setSelectSql("select * from employee");

//to create the navigation bars for the table
masterTable.createControlPanel();

//listen for any row changes in the master table
//once a new row is selected, fill the detail table with corresponding related information
masterTable.addDBTableEvenetListener(new DBTableEventListener()
{

public void afterRowSelectionChange(int fromRow, int toRow)
{
//get the primary key value from master table
//and query the detail data with the primary key

detailTable.setSelectSql("select * from employee_details where emp_id=" + masterTable.getValueAt(toRow, 1));

try{
detailTable.refresh();
}catch(Exception ex)
{
ex.printStackTrace();
}
}
};


try
{
//connect to database & create a connection
masterTable.connectDatabase();

//assign this database connection to detail table also.
detailTable.setConnection(masterTable.getConnection());

//fetch the data from database to fill the table
masterTable.refresh();
}
catch(SQLException e)
{
e.printStackTrace();
}
catch(ClassNotFoundException e)
{
e.printStackTrace();
}

}

public static void main(String[] args)
{
//create a new table frame
QuickTableFrame myframe = new QuickTableFrame();
}
}


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