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
Invalid row 0 passed printer friendly version
next newest post | next oldest post
Author Messages
mexican
Private First Class

Gender: Male
Location: Mexico city
Registered: Sep 2008
Status: Offline
Posts: 12

Click here to see the profile for mexican Send email to mexican Send private message to mexican Find more posts by mexican Edit or delete this message Reply w/Quote
Posted Sunday, September 21, 2008 @ 00:40:49  

HI again, I{m triying to implement a filter but I get this error:
Invalid row 0 passed for parameter row in the method goToRow(int row). Valid rows range [0,0]
I set my DBTable.debug = true but I get nothing else to indicate what´s wrong : here's my code:

filterText = new JTextField();
filterText.setColumns(10);
filterText.setAlignmentY(Component.CENTER_ALIGNMENT);
jb2.add(filterText);
//jb2.add(lstConsultores);
filterButton = new JButton("Consultar");
filterButton.setMargin(i1);
filterButton.setAlignmentY(Component.CENTER_ALIGNMENT);
filterButton.addActionListener(this);
jb2.add(filterButton);
panel3.add(jb2,BorderLayout.NORTH);

//crea la sentencia que sera usada por la tabla
voTabla3.setSelectSql("SELECT IRC_ID, IRC_IPR_ID_PERIODO, IRC_ICN_ID_CONSULTOR, IRC_NOMBRE_CLIENTE, IRC_NOMBRE_PROYECTO, " +
"IRC_HORAS FROM INF_RPTPROYECTOS_CLIENTES");

//sentencia de update
voTabla3.addUpdateSql("UPDATE INF_RPTPROYECTOS_CLIENTES SET IRC_IPR_ID_PERIODO =?, IRC_ICN_ID_CONSULTOR =?," +
" IRC_NOMBRE_CLIENTE =?, IRC_NOMBRE_PROYECTO =?, IRC_HORAS =? WHERE IRC_ID =?", "2,3,4,5,6,1");

//sentencia de insert
voTabla3.addInsertSql("INSERT INTO INF_RPTPROYECTOS_CLIENTES(IRC_IPR_ID_PERIODO, IRC_ICN_ID_CONSULTOR, "+
"IRC_NOMBRE_CLIENTE, IRC_NOMBRE_PROYECTO, IRC_HORAS) values (?,?,?,?,?)",
"2,3,4,5,6");

//sentencias delete
voTabla3.addDeleteSql("DELETE FROM INF_RPTPROYECTOS_CLIENTES WHERE IRC_ID = ?", "1");

try {
//obtiene la conexion establecida
voTabla3.setConnection(con);
//obtiene los datos para llenar la tabla
voTabla3.refresh();
voTabla3.getTable().setAutoResizeMode(JTable.AUTO_RESIZE_ALL_COLUMNS);
voTabla3.setControlPanelVisible(true);
voTabla3.createColumnModelFromQuery();
voTabla3.getColumn(1).setBoundSql("SELECT IPR_ID_PERIODO,IPR_PERIODO FROM INF_PERIODOS_REPORTES");

//restringiendo las columnas
Column voidClte = voTabla3.getColumn(0);
voidClte.setHeaderValue("CLAVE REGISTRO");
Column voPeriodo = voTabla3.getColumn(1);
voPeriodo.setHeaderValue("PERIODO");
Column voConsultor = voTabla3.getColumn(2);
voConsultor.setBoundSql("SELECT ICN_ID_CONSULTOR, ICN_NOMBRE||' '||ICN_APATERNO||' '||ICN_AMATERNO FROM INF_CONSULTORES");
voConsultor.setHeaderValue("CONSULTOR");
Column voNbClte = voTabla3.getColumn(3);
voNbClte.setType(Types.VARCHAR);
voNbClte.setLength(80);
voNbClte.setHeaderValue("CLIENTE");
Column voNbPry = voTabla3.getColumn(4);
voNbPry.setType(Types.VARCHAR);
voNbPry.setLength(90);
voNbPry.setHeaderValue("NOMBRE PROYECTO");
Column voHrs = voTabla3.getColumn(5);
voHrs.setType(Types.VARCHAR);
voHrs.setLength(9);
voHrs.setHeaderValue("HORAS UTILIZADAS");

} catch (SQLException e) {
e.printStackTrace();
}

//Establece si se puede o no escribir en la tabla
voTabla3.getColumn(0).setReadOnly(true);
voTabla3.getColumn(1).setReadOnly(false);
voTabla3.getColumn(2).setReadOnly(false);
voTabla3.getColumn(3).setReadOnly(false);
voTabla3.getColumn(4).setReadOnly(false);
voTabla3.getColumn(5).setReadOnly(false);

voTabla3.debug = true;
voTabla3.addDatabaseChangeListener(LsterTabla3);

panel3.add(voTabla3, BorderLayout.CENTER);
tabbedPane.addTab("Proyectos Clientes", null, panel3, "Proyectos Clientes");

//Cuarto Panel Catalogo Proyectos Internos
JPanel panel4 = new JPanel(new BorderLayout());

////////And in my ActionPerformed method I have:

public void actionPerformed(ActionEvent e) {
else if (e.getSource() == filterButton) {
String filterString = filterText.getText();

//if the user has entered any valid filter text
if (filterString != null && !("".equals(filterString))) {
Vector prueba = new Vector();
prueba = voTabla2.getDataVector();
//System.out.println("que hay: "+prueba.toString());
//search the first column , for the filter text
voTabla2.filter(0, DBTable.EQUAL, filterText.getText());
} else {
//show all the records without filtering
voTabla2.filter(null);
}

I print the Vector prueba to see if the table was returning data and indeed it has data in it.
What could be wrong? :(

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, September 21, 2008 @ 18:05:57  

Is it possible that the first column does not have any rows matching filter text?

voTabla2.filter(0, DBTable.EQUAL, filterText.getText());

On another possibility is that, the data in the actual cell is not a String data type, so when you compare it always fails, so none of the rows match?

mexican
Private First Class

Gender: Male
Location: Mexico city
Registered: Sep 2008
Status: Offline
Posts: 12

Click here to see the profile for mexican Send email to mexican Send private message to mexican Find more posts by mexican Edit or delete this message Reply w/Quote
Posted Sunday, September 21, 2008 @ 22:40:58  

well the data in that cell is NUMERIC type, but if this the error, how do I fix it? Do I have to pass an integer type to the filter? and another question: is it possible to have a filter like this: select certain data from employees where employee_name equals something and employee type equals something and numbers_of_work_hours equals something? or the fiter class works only for one condition?

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 Monday, September 22, 2008 @ 10:03:39  

below method is just a helper method provided for simple filter cases
voTabla2.filter(0, DBTable.EQUAL, filterText.getText());

You don't need to use the above method. Instead you can filter using the Filter class.

dbTable.filter(Filter filter)

All you need to do is write your own logic to find the rows which are matching the filter criteria and return the filtered rows array for the below method in your Filter implementation

public int[] filter(TableModel tm)

Refer below for api and sample implementation
http://quicktable.org/doc/quick/dbtable/Filter.html

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