Custom Filtering on particular column

* To change this template, choose Tools | Templates
* and open the template in the editor.
* @author Neelam Sharma
import java.awt.BorderLayout;
import java.awt.Dimension;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.util.ArrayList;
import java.util.List;
import javax.swing.Box;
import javax.swing.JButton;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JPanel;
import javax.swing.JScrollPane;
import javax.swing.JTable;
import javax.swing.JTextField;
import javax.swing.RowFilter;
import javax.swing.RowFilter.ComparisonType;
import javax.swing.RowSorter;
import javax.swing.SortOrder;
import javax.swing.table.DefaultTableModel;
import javax.swing.table.TableModel;
import javax.swing.table.TableRowSorter;
public class RegexTable {
public static void main(String args[]) {
JFrame frame = new JFrame("Regexing JTable");
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
Object rows[][] = {{"A", "About", 44.36, 34}, {"B", "Boy", 44.84, 20}, {"C", "Cat", 463.63, 15},
{"D", "Day", 27.14, 67}, {"E", "Eat", 44.57, 57}, {"F", "Fail", 23.15, 20},
{"G", "Good", 4.40, 44}, {"H", "Hot", 24.96, 46}, {"I", "Ivey", 5.45, 38},
{"J", "Jack", 49.54, 90}, {"K", "Kids", 280.00, 17}};
String columns[] = {"Symbol", "Name", "Price", "Age"};
TableModel model = new DefaultTableModel(rows, columns) {
public Class getColumnClass(int column) {
Class returnValue;
if ((column >= 0) && (column < getColumnCount())) {
returnValue = getValueAt(0, column).getClass();
} else {
returnValue = Object.class;
return returnValue;
final JTable table = new JTable(model);
final TableRowSorter<TableModel> sorter = new TableRowSorter<TableModel>(model);
table.setRowSorter(sorter);
JScrollPane pane = new JScrollPane(table);
frame.add(pane, BorderLayout.CENTER);
JPanel panel = new JPanel(new BorderLayout());
JLabel label = new JLabel("Filter");
panel.add(label, BorderLayout.WEST);
final JTextField filterText = new JTextField();
panel.add(filterText, BorderLayout.CENTER);
frame.add(panel, BorderLayout.NORTH);
//regular expression
JButton regexFilterButton = new JButton("Regular Expression");
regexFilterButton.setPreferredSize(new Dimension(80, 20));
regexFilterButton.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
String text = filterText.getText().trim();
if (text.length() == 0) {
sorter.setRowFilter(RowFilter.notFilter(RowFilter.regexFilter(text)));
} else {
sorter.setRowFilter(RowFilter.regexFilter(text));
//before number
JButton dataFilterButton = new JButton("Before Number");
dataFilterButton.setPreferredSize(new Dimension(80, 20));
dataFilterButton.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
String text = filterText.getText().trim();
int intText = Integer.parseInt(text);
if (text.length() == 0) {
sorter.setRowFilter(RowFilter.notFilter(RowFilter.regexFilter(text)));
} else {
sorter.setRowFilter(RowFilter.numberFilter(ComparisonType.BEFORE, intText));
//after number
JButton afterNumberButton = new JButton("After Number");
afterNumberButton.setPreferredSize(new Dimension(80, 20));
afterNumberButton.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
String text = filterText.getText().trim();
int intText = Integer.parseInt(text);
if (text.length() == 0) {
sorter.setRowFilter(RowFilter.notFilter(RowFilter.regexFilter(text)));
} else {
sorter.setRowFilter(RowFilter.numberFilter(ComparisonType.AFTER, intText));
//Equal
JButton equalNumberButton = new JButton("Equal Number");
equalNumberButton.setPreferredSize(new Dimension(80, 20));
equalNumberButton.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
String text = filterText.getText().trim();
int intText = Integer.parseInt(text);
if (text.length() == 0) {
sorter.setRowFilter(RowFilter.notFilter(RowFilter.regexFilter(text)));
} else {
sorter.setRowFilter(RowFilter.numberFilter(ComparisonType.EQUAL, intText));
//Not Equal
JButton NotEqualNumberButton = new JButton("Not Equal Number");
NotEqualNumberButton.setPreferredSize(new Dimension(80, 20));
NotEqualNumberButton.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
String text = filterText.getText().trim();
int intText = Integer.parseInt(text);
if (text.length() == 0) {
sorter.setRowFilter(RowFilter.notFilter(RowFilter.regexFilter(text)));
} else {
sorter.setRowFilter(RowFilter.numberFilter(ComparisonType.NOT_EQUAL, intText));
Box boxbottom = Box.createHorizontalBox();
boxbottom.add(Box.createHorizontalGlue());
boxbottom.add(regexFilterButton);
boxbottom.add(Box.createHorizontalStrut(5));
boxbottom.add(dataFilterButton);
boxbottom.add(Box.createHorizontalStrut(5));
boxbottom.add(afterNumberButton);
boxbottom.add(Box.createHorizontalStrut(5));
boxbottom.add(equalNumberButton);
boxbottom.add(Box.createHorizontalStrut(5));
boxbottom.add(NotEqualNumberButton);
frame.add(boxbottom, BorderLayout.SOUTH);
frame.setSize(600, 500);
frame.setVisible(true);
Its my program. In this I want custom filtering on "Age" column so that when I give 44 in text field of "Filter" then it should display 44 for "Age" column only. How can I customize my filtering?? Also how can I get the result for Query through that "select * from table where Name='Boy and Age=20 ang Price=44.84'" ??
Edited by: Neelam.Sharma on Jun 30, 2009 11:37 AM

Why is it that you can figure out how to use the "Bold" button, but you can't figure out how to use the "Code" button. Try using the "Preview" button to figure out which button is more usefull when posting code. I for one can't be bothered to read unformatted code.I don't think the OP masters the "bold" button either. The markup for bold formatting is the star '*', I guess we just witness his/her javadoc comments being misinterpreted as bold formatting :o)

Similar Messages

  • Need help in hiding particular column of a table depending upon value

    Hi experts,
    I have developed a custom smartform and Print program.
    My problem is ..depending upon the data i recieve,...i have to hide a particular column.
    For example ... i have a table with 2 rows...one header and main row..This table has 3 column.
    I have to hide one of the column depending upon the data i recieve. So my output should have 2 rows and 2 columns.
    Please help.

    well vishwa u r right it wont work for multiple columns,
    then i guess this shud work.
    @thendral
    U can try like this create the rows with single column
    then print all ur text elements with spaces inserted manually between them with text editor then in conditions tab of the text elements specify ur condition according to what all u want to print.
    кu03B1ятu03B9к

  • Display a particular column only when certain criteria is satisfied

    Hi Experts,
    I have a requirement from a user with which i am struggling. The person wants to see an entire report but see a particular column only when certain criteria is satisfied. I am not talking about filtering the entire Query but just a certain column.
    Ex.
    Data in Cube
    Req | Candidate | Candidate Status | Grade
    1 | C01 | Draft | A
    1 | C02 | Withdrawn | B
    2 | C03 | Hired | B
    3 | C04 | In Process | A
    3 | C05 | Hired | C
    Result in Query
    Req | Candidate | Grade
    1 | <Blank> | A
    1 | <blank> | B
    2 | C03 | B
    3 | <blank> | A
    3 | C05 | C
    Basically, user wants to see candidate information only when Status is Hired. Rest of the time, it should be blank.
    Is this possible ?

    Hi,
    From My view this is not possible in Query.
    You can do this in Backend or
    You can create 2 Query
    1.Query whith candidate name who is hired.
    2.Query without candidate name whose status is not hired.
    3.Merge these these report using Excel Macro.
    Thanks and Regads,
    MuraliManohar

  • Prevent dashboard prompt from filtering a particular report on page?

    I have a dashboard page with 1 prompt and 5 reports. The first object on the dashboard page is a dashboard prompt with a date range for created date.
    The request is to filter the first 4 reports based on the dashboard prompt, and then the last report NOT be filtered based on the prompt.
    Right now - the date range entered in the dashboard prompt is filtering all 5 reports.
    Is there any way to prevent the prompt from filtering a particular report on the dashboard page?
    Thanks!

    Just wanted to provide an update as to what I learned from the SR I opened.
    Dashboard prompts apply to all reports on the page which either:
    * Have the "is prompted" filter selected
    - OR -
    * Are filtered in any other way
    In my case, my last report was filtered on the created date to exclude any data prior to July 1, 2010. Because this hardcoded filter was applied, then the report automatically was picking up the date range filter from the dashboard prompt and applying that date range to the report instead.
    The workaround was to create a new column on the report formatting the date as YYYYMM and applying a filter to the report as >= 201007. With this, the dashboard prompt is now not applied to filter this report.

  • Set a particular column's Color when importing a list to Excel

    Hi all,
    I am displaying a list by using REUSE_ALV_LIST_DISPLAY.
    It works fine.Now i import this List to Excel sheet by custom program to set the formatting part and for color prospect which is not working with standard Import functionality.I am using the Methods of Interface  I_OI_SPREADSHEET.
    Now my query is that how to set a particular column's Color ?
    And how to set the width of a particular column ?
    Suggess.
    Points will be sured.
    Thanks
    Sanket sethi

    check this
    downloading my report output with the same color on my report to excel .
    Download alv output to an excel file

  • How to change the particular column background  color in jTable?

    I am woking with a project, in which I am using a jTable. Then
    How to change the particular column background color in jTable?

    Use a custom Renderer. This is the JTable tutorial:
    http://java.sun.com/docs/books/tutorial/uiswing/components/table.html

  • Table filtering on number columns

    Hi!
    Is it possible to do table filtering on number columns such as: > 10
    Br
    Casper
    Edited by: Casper Thrane on 05-May-2011 05:13

    Hi,
    I have never tried filtering by equality or relational operators, but with some tinkering I think it might be possible.
    If you haven't already checked, there are some really good how-to's on customizing the ADF table filter at Oracle ADF Code Corner.
    Specifically, Custom Table Filter and Filter by date range
    Edited by: Paendrag on May 5, 2011 7:39 AM

  • Different filters to different columns

    Hello!
    Is there any possibility to assign in criteria tab some filters to one column and anothers to other column??
    Because in one column I don't want to affect some filter.
    Thank you!

    Hi..
    Yes,
    As naresh said.. use inner filters.
    click on fx of particular column.
    click on filters then select dimension from left pane then apply the filter..
    But remember..
    To apply inner filter, that column must be Measure and Aggregated in rpd.
    Thanks & Regards
    Kishore Guggilla

  • Web item "TABLE" -- How to hide rows of a particular column.

    HI,
       In the web item "table", is there anyway that i can hide the rows of a particular column(for example: material column) except the result rows.
    Here is the Query result:
    Customer
    Material
    KF1
    KF2
    KF3
    Result__________________________400_____700____300
    1001_________________Result_____150_____300____150
    _____________________10_________100_____200____100
    _____________________20_________50______100____50
    1002_________________Result_____250_____400____150
    _____________________10_________100_____200____100
    _____________________20_________150_____200____50
    After formatting the query result looks like:
    Customer
    Material
    KF1
    KF2
    KF3
    Result__________________________400_____700____300
    1001_________________Result_____150_____300____150
    1002_________________Result_____250_____400____150
    How can i hide the item rows except the "Result" rows of the material column?
    regards,
    ravi

    Dear Ravi,
    look in the BW WEB API Documentation on help.sap.com for more details (or just search in SDN for it).
    In General:
    - create class which inherit from CL_RSR_WWW_MODIFY_TABLE
    - redifine method CHARACTERISTIC_CELL
    - insert coding:
      if i_iobjnm eq '0MATERIAL' and i_IS_SUM is initial.
      free C_CELL_CONTENT.
      endif.
    - Insert the parameter MODIFY_CLASS with the name of your new class into your template
    result: you see the result of the column but not the single values.
    Hope this answer your question.
    Regards Marcus
    Message was edited by: Marcus Pospiech

  • Filter  only records which has particular column initial

    Hi friends
      I am using filter for a table view, in my talbe for a particular column , it has initial values also for some records,
      my question is how the user can filter only the records that has the particular column value is initial.
       what has to write in the filter field

    i am not sure how you can handle it with FILTER = SERVER
    but if you set it to APPLICATION, then you can write your own logic . for filtering. in this case in the filter field you may request the user to enter "INITIAL" to search for initial values. This text  "INITIAL" you can capture in your oninputprocessing and filter the table.
    other option (not exactly FILTER) is to set sort = SERVER and user can do ascending sort to see the initial value records first.
    Regards
    Raja

  • While creating the parameter it doesnot pull all the data of that particular column

    Post Author: pvds
    CA Forum: Data Connectivity and SQL
    Hi everyone.
    i am using a sql query with a join condition to pull data in to crystal reports. I got that data which i want in to the report. but when i was trying to create a parameter with a dropdown of all the database values to a particular column it is not showing all the data from the report.
    for example  i have a column called state
    the column has many states displayed in the report but when i select that column and select browse data it shows only 1 state. with this i am anable to create a parameter with a dropdown list of all the state. i can see different states in the report but y i am not able to see when i browse the data or create a parameter? can any one answer me?
    i already created another report with a query on same table but i never faced this problem before.

    Post Author: V361
    CA Forum: Data Connectivity and SQL
    There is a limit to the number of Parameters that will show in a drop down... You can increase using the following.
    Check this KBase article on how to increase the number.
    http://technicalsupport.businessobjects.com/KanisaSupportSite/search.do?cmd=displayKC&docType=kc&externalId=c2017238&sliceId=&dialogID=19032644&stateId=1%200%2019034607

  • Hotspot click for only some rows in ALV grid for a particular column ?

    Hi there,
            In ALV grid, we can make Hotspot enable for all rows in a specified column
    by specifying in the fieldcatalog with Hotspot attribute set as true.
    But I want to enable Hotspot only for certain rows in the particular column. I tried with MC_STYLE4_LINK , but I didnt got the required result.
    So , how could I achieve that in ALV grid.
    Points would be rewarded for helpful answers.
    Regards,
    Anil .

    Hi,
    You can do it for a column. Please refer to the code snippet below,
      DATA : it_fcat TYPE lvc_t_fcat,
             wa_fcat LIKE LINE OF it_fcat.
    CALL FUNCTION 'LVC_FIELDCATALOG_MERGE'
       EXPORTING
      I_BUFFER_ACTIVE              =
         i_structure_name             = 'SMMW_ALERTS_ICON_S'
      I_CLIENT_NEVER_DISPLAY       = 'X'
      I_BYPASSING_BUFFER           =
      I_INTERNAL_TABNAME           =
        CHANGING
          ct_fieldcat                  = it_fcat
       EXCEPTIONS
         inconsistent_interface       = 1
         program_error                = 2
         OTHERS                       = 3
    LOOP AT it_fcat INTO wa_fcat.
      IF wa_fcat-fieldname = 'STATUS'.
        wa_fcat-hotspot = 'X'.
        MODIFY it_fcat FROM wa_fcat.
        CLEAR wa_fcat.
      ENDIF.
    ENDLOOP.
    CALL METHOD l_obj_alv_grid->set_table_for_first_display
          EXPORTING
        i_structure_name              = 'SMMW_ALERTS_ICON_S'
       CHANGING
            it_outtab                     = lt_alerts_st
            it_fieldcatalog               = it_fcat.
    In the above replace the structure 'SMMW_ALERTS_ICON_S' with your structure and column 'STATUS' with your desired column.
    Hope this helps,
    Regards,
    Vinodh

  • Query throws an error while drilldowning a particular column in production

    Hello Gurus,
    There is an issue in a query when I run it on portal and when I try to drill down one particular column, it throws an error. I am pasting the error message below for your reference. This query works fine when I run in Bex. It also works fine when I run it on Quality portal. It only throws an error when I run it on production portal. I have got the patches and PI checked with BASIS team, everything seems to be fine.
    Please help me out with this issue.
    Termination message sent
    ABEND RSBOLAP (000): Program error in class SAPMSSY1 method : UNCAUGHT_EXCEPTION
      MSGV1: SAPMSSY1
      MSGV3: UNCAUGHT_EXCEPTION
    com.sap.ip.bi.base.application.exceptions
    ABEND: Program error in class SAPMSSY1 method : UNCAUGHT_EXCEPTION
    ABEND: System error in program SAPLRRK0 and form LRECH_01-01- (see long text)
    Regards,

    Hi,
    There are a couple of threads on the same issue.
    Refer to these, just might be handy.
    Re: Uncaught_exception in Report Designer
    Program error in class SAPMSSY1 method  : UNCAUGHT_EXCEPTION in Report
    Good Luck!
    Sandeep Tudumu

  • How to create event alert for particular column get updated

    Hi every one.... plz help me
    How to create oracle event alert when particular column is update. plz help me.... Acutually i need email alert when ever list price for an item column in pricing table get updated+... plz. Its urgent.

    Oracle Event alert is based on update of specific table and not on specific column in table.
    However you can create a trgigger on table which is based on updat of column. And in this trigger you can send a mail using plsql.
    HTH

  • How to get details of a particular column in database.

    Hi dear friends,
    I am getting error while i try to get index information on a particular column.
    here is the code.. why it gives me error
    import java.sql.*;
    import java.util.StringTokenizer;
    public class TestIndex {
      final static String jdbcURL = "jdbc:timesten:client:CATSREPLICATION";
      final static String jdbcDriver = "com.timesten.jdbc.TimesTenClientDriver";
      final static String scheme = "CATSPROD";
      public static void main(java.lang.String[] args) {
        System.out.println("--- Database Viewer ---");
        try {
          Class.forName(jdbcDriver);
          Connection con = DriverManager.getConnection(jdbcURL, "", "");
          DatabaseMetaData dbmd = con.getMetaData();
          System.out.println("Driver Name: " + dbmd.getDriverName());
          System.out.println("Database Product: " + dbmd.getDatabaseProductName());
            // Get a list of all the indexes for this table
          // this MYSCHEME.TABLENAME has a composite unique key on 2 columns of it.
           * create table MYSCHEME.TABLENAME (id integer not null, name varchar(25) not null);
           * create unique key on MYSCHEME.TABLENAME(id,name);
            ResultSet indexList = dbmd.getIndexInfo(null,null,"MYSCHEME.TABLENAME",true,false);
            ResultSet columns = null;
            indexList.next();
            while(indexList.next()) {
              System.out.println(" Index Name: "+indexList.getString("INDEX_NAME"));
              String column = indexList.getString("COLUMN_NAME");
              System.out.println(" Column Name:"+column);
              columns =  dbmd.getColumns(null,"MYSCHEME","TABLENAME",column);
              System.out.println("---------------------------");
              System.out.println(columns.getString("IS_NULLABLE"));
              System.out.println("---------------------------");
            indexList.close();
          con.close();
        catch (ClassNotFoundException e) {
          System.out.println("Unable to load database driver class");
        catch (SQLException e) {
          System.out.println("SQL Exception: " + e.getMessage());
    it give error
    SQL Exception: Invalid cursor state
    why?
    thanks a lot
    Veena
    [ November 10, 2005: Message edited by: Veena Gupta ]

    indexList.next();
    while(indexList.next()) {You will be missing the first record due to this.
    columns =
    dbmd.getColumns(null,"MYSCHEME","TABLENAME",column);
    System.out.println("---------------------------");
    System.out.println(columns.getString("IS_NULLABLE"));You need to call columns.next() before using the getString(). If next() is not called, the cursor of the ResultSet is positioned before the first record and an attempting to read a record before positioning the cursor to the first record would result in an exception due to invalid cursor state.

Maybe you are looking for

  • Photoshop says it's running in Trial mode.

    Hi there, 10 days ago I purchased the Lightroom+Photoshop package. I went on to install that on my Mac Pro but now everytime I open Photoshop it pops open the Adobe Application Manager who reminds my that there are X days remaining on my Photoshop tr

  • TDS Deduction on Vendor Payment

    Hi While booking the invoice (through FB60) if I forget to delete the WTax Code for payment, then how can I rectify the same, so that TDS is not deducted again at the time of making payment. One way is to reverse the document through FB08. Is there a

  • Reconstructing a string from a database retrieval

    What is the correct way to retrieve data such as a string from a database? If I inputing data to the database like this... std::string inputString = "hello world"; data.data = &inputString; data.size = inputString.size(); ret = dbp->put(dbp, NULL, &k

  • How to populate manager field of user while recon

    Hi, I want to populate Manager field while recon. In recon i am getting manager's employee number for particular user so i have to fetch name for that number and i have to map to manager field for that particular user in oim how can i acheive this, i

  • Shouldn't the ring/silent switch silence all sounds?

    Shouldn't the ring/silent switch silence all sounds at a system level, including those made by third-party apps? That's how my Treo worked, and it worked well. (I'm aware that clock alarms still ring, regardless of the setting, as pointed out in the