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
Filtering on clolumn headers printer friendly version
next newest post | next oldest post
Author Messages
khan379
Corporal

Gender: Male
Location:
Registered: Dec 2007
Status: Offline
Posts: 29

Click here to see the profile for khan379 Send email to khan379 Send private message to khan379 Find more posts by khan379 Edit or delete this message Reply w/Quote
Posted Friday, December 21, 2007 @ 10:41:33  

Hi,
Does anyone have an idea how I can perform filtering by clicking on the column headers as we do in MS Excel.
when I click on the column header a dropdown should show all the column values which I can check or uncheck for filtering.

any idea shall be very helpful for me.
Thanks.

--------------------
A H Khan

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 Friday, December 28, 2007 @ 12:16:17  

You need to implement this your own.

First get the tableheader of Quicktable

dbTable.getTable().getTableHeader();

Add a mouse click listener to the header. By default quicktable will sort the rows when you click on column header. To prevent that, set dbtable.setSortEnabled(false);

when mouseclicked, identify the column which is clicked.

Then find all distinct values in that column. There are two approaches to do this.
1) Every time, go through all rows of that column and using dbtable.getValueAt(), get the values of the cell and store in a 'Set'(Collection) to make them unique. Using this set object create a combobox and show to users.
2) First time when you load data, go through all cells and using dbtable.getValueAt(), get the values and store them in a 'Set' object per column. Any time when users make any change to any cell, update the appropriate column Set. Use a DBTableCellListener
to listen for cell value changes.

Once user selects a value to filter by that value, use the dbtable filter method

dbTable.filter(1 /*column id*/, DBTable.EQUAL /*criteria*/, value /*filter value*/)

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