Want to hide Jtable column

i want to hide Jtable's column and its data but the point is data should remains in table model
or we can say we acces that data any where from this method.
table.getModel().getValueAt(...)
below is the code which i used to hide column from table.
table coulmn tb= priceTable.getColumn(priceTable.getColumnName(2));
TableColumnModel tcm= priceTable.getColumnModel();
tcm.removeColumn(tb);
but the problem is that this column data still show in table.column already hide.
what i do for it?

Setting a column's width to zero -- a hack.
Using removeColumn -- priceless ;-)
Works for me:
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
import javax.swing.table.*;
public class TableExample implements Runnable, ActionListener {
    private JTable table;
    private TableColumn tc;
    public void run() {
        table = new JTable(10,10);
        JToggleButton btn = new JToggleButton("toggle column A's visibility");
        btn.addActionListener(this);
        JFrame f = new JFrame("TableExample");
        f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
        f.getContentPane().add(new JScrollPane(table), BorderLayout.CENTER);
        f.getContentPane().add(btn, BorderLayout.SOUTH);
        f.pack();
        f.setLocationRelativeTo(null);
        f.setVisible(true);
    public void actionPerformed(ActionEvent evt) {
        TableColumnModel tcm = table.getColumnModel();
        if (tc==null) {
            tc = tcm.getColumn(0);
            tcm.removeColumn(tc);
        } else {
            tcm.addColumn(tc);
            tcm.moveColumn(tcm.getColumnCount() - 1, 0);
            tc = null;
    public static void main(String[] args) {
        EventQueue.invokeLater(new TableExample());
}

Similar Messages

  • I want to hide a column in report 6i

    hi
    I want to hide a column in report 6i,
    I used this code
    function F_col_qty3FormatTrigger return boolean is
    begin
    if :color3 is null then
         return (false);
         else
    return (TRUE);
    end if;
    end;
    plz note that COL_QTY3 and COLOR3 both are from different table
    and resulting gave this error
    REP-1314 Format trigger 'F_col_qty3' reference column 'color3' at wrong frequency.

    You can format fields from a lower level group using fields from an upper level field, but not vice versa. This is because for the same upper level field there may exist several values of the lower level field. If this can not happen in your situation, there is no reason to place the fields in different groups.

  • Report painter-want to hide period columns dynamically if the period is not closed

    Hi All,
    I have made report with 12 columns like JAN, FEB till DEC in report painter (GRR1)
    Requirement is that if say, currently only period no.4(APR) is closed and we are in period no.5( MAY) or system date is in MAY, then the report should not show the data for the current period no.5(MAY), eventhough data is there. Or else it should show data for JAN to APR (closed periods)
    For this I defined 12 different period formula variables in GS11, based on system paramters like
    S008 Year (from Local System Date)
    S002 Month (from Local System Date)
    S003 Day of Month (from Local System Date)
    S012 Current Period in Current Year (per CO Fiscal Yea
    But the issue is that eventhough the variable is defined as formula variables, still the default values are given by system and default value only getting passed to the report and thus data is displayed for the unclosed period.
    But SAP help says that formula variables are without default values unlike the value type variable.
    Any help in this will be highly appreciated.

    Hi All,
    I have cracked it and got the solution with redefining the formula variables.
    Details
    JAN
    FEB
    MAR
    APR
    MAY
    JUN
    JUL
    AUG
    SEP
    OCT
    NOV
    No.of days in each Month
    31
    28
    31
    30
    31
    30
    31
    31
    30
    31
    30
    day number in year
    31
    59
    90
    120
    151
    181
    212
    243
    273
    304
    334
    result available after 15 days
    47
    75
    106
    136
    167
    197
    228
    259
    289
    320
    350
    Formula variable definition for 11 months in current year
    ZTPFR01
    ZTPFR02
    ZTPFR03
    ZTPFR04
    ZTPFR05
    ZTPFR06
    ZTPFR07
    ZTPFR08
    ZTPFR09
    ZTPFR10
    ZTPFR11
    IF '#S005' <47 
    IF '#S005' <75
    IF '#S005' <106 
    IF '#S005' <136
    IF '#S005' <167
    IF '#S005' <197
    IF '#S005' <228
    IF '#S005' <259
    IF '#S005' <289
    IF '#S005' <320
    IF '#S005' <350
    THEN 1
    THEN 2
    THEN 3
    THEN 4
    THEN 5
    THEN 6
    THEN 7
    THEN 8
    THEN 9
    THEN 10
    THEN 11
    ELSE 0
    ELSE 0
    ELSE 0
    ELSE 0
    ELSE 0
    ELSE 0
    ELSE 0
    ELSE 0
    ELSE 0
    ELSE 0
    ELSE 0

  • How to hide the column in JTable

    Hi
    I want to hide a column . But I would be needing the data in that column. ( I have 4 columns )
    I want to hide 4th column
    I have done these steps
    MyTableModel  myTableModel= new  MytableModel(t);
    myTable  = new JTable(myTableModell);                 
    mTable.getColumnModel().removeColumn(myTable.getColumnModel().getColumn(3));When I trying to read the column 1 value it is giving the exception
    myTable.getValueAt(row,3).toString();It is giving the arrayboundexception
    Can anybody tell me what is the correct method to do ?
    Thanks and regards
    Anshuman

    Thanks for reply .
    I have taken the value as the convertRowToModel
    WalterLaan wrote:
    You get an exception because the table doesn't have a column at index anymore, but you can still ask the model.
    table.getModel().getValueAt(table.convertRowToModel(row), 3);
    But it is giving the same error
    java.lang.ArrayIndexOutOfBoundsException: 4 >= 4
         at java.util.Vector.elementAt(Unknown Source)
         at javax.swing.table.DefaultTableColumnModel.getColumn(Unknown Source)
         at javax.swing.JTable.convertColumnIndexToModel(Unknown Source)
         at javax.swing.JTable.getValueAt(Unknown Source)Edited by: techie_india on Jul 6, 2009 10:38 PM

  • Hide a column in JTable

    Dear all,
    I want to hide a column in JTable object, I already tried resize it to 0 but the effect is not good, I also cannot remove the column, since I need this column for other process.
    So, any other good idea besides resizes and remove?
    Thank you very much!

    I have tried that too, but the column isn't hide, the size is not actually come to 0,...That's because JTable has a default minimum width of 15.... if you want to hide the column, you must set the minwidth as well. For example:
    myTable.getColumnModel().getColumn(column_to_hide).setMinWidth(0);
    myTable.getColumnModel().getColumn(column_to_hide).setPreferredWidth(0);;o)
    V.V.

  • SSRS 2005 - Dynamically control the width of columns in Matrix report or Hide any column

    Hi All,
    I just want to hide some column without having white space in Matrix report in SSRS 2005. Although I am aware of that perhaps this feature is not available on SSRS 2005. So, I just want to know if we can handle the width of column dynamically(using expressions)
    in matrix report?
    Please help. Thanks in Advance.
    Regards
    Kumud

    Hi Kumud,
    Based on my test, SSRS is not support column dynamically width. It has property “CanGrow” of text box. If we configure the property to True, it will wraps to next line if needed. In SSRS 2008, we can hide some columns without white space. If possible, I
    recommend you update your SSRS 2005 to SSRS 2008.
    There is a similar issue, you can refer to it.
    http://social.msdn.microsoft.com/Forums/sqlserver/en-US/9e6043f1-c458-4540-be59-d37b02feab8a/dynamic-column-width-for-a-report?forum=sqlreportingservices
    Alternatively, I recommend you that submit a wish to the Microsoft Connect at
    https://connect.microsoft.com/SQLServer/Feedback. Your feedback is valuable for us to improve our products and increase the level of service provided.
    Regards,
    Alisa Tang
    Alisa Tang
    TechNet Community Support

  • How to hide the columns at the end user level thru personalization

    Hi all
    how I can hide the columns that are displayed on the portal. Any personalize option for the end user? Any righ click or some thing?
    I am looking at hiding columns not while developing the iViews / Pages, But in the browsers as the end user.
    i can hide the columns what ever i want while creating the iViews for MDM data. but we cant provide the content administrator role to the end user for hiding the columns what ever they want. they want to hide the columns thru pesonalization option at the end user level.
    Can you please let me know whether we can able to hide the columns at the end user level thru personalization ?? is it posible with standard iViews??
    Regards
    Sunil

    Hi Sunil,
    I understood your requirement properly and seems valid and I tried this at my end but i didnt get the solution. Field list is not visible in Personalize option. I dont think it is possible with MDM standard iViews.
    I was thinking an alternative is if some how we manage to give the permissions to end user only on Result Set iView but if it would be possible it will not be a good design.
    Lets wait for some inputs from others.
    Regards,
    Jitesh Talreja

  • Hide a Column in ALV Grid Output

    Hi,
    I want to hide a column in ALV Grid Output through program.
    I am using   lwa_fieldcat-NO_OUT = 'X'. to hide the column in output but it is not working, column in not hided in the output.
    Kindly suggest.

    It should work..
    see the code :
    d_fieldcat_wa-fieldname = 'MATNR'.
    d_fieldcat_wa-seltext_l = 'material number'.
    d_fieldcat_wa-no_out = 'X'. * hide particular field
    append d_fieldcat_wa to d_fieldcat.
    clear d_fieldcat_wa.
    if not please paste your code here.
    Thanks
    Seshu

  • Hide some columns in alv if no values are present for that columns ..

    Hi all,
    This looks like a wierd requirement ..In my ALV report, i am displaying around 30 fields. Among those , based on the input ,data will not be there for some  of the columns .. In the output we want to hide those columns
    eg:
    Matnr     Descr    Column3  Column4
    Mat1      Des1     (No data)  sfsfs
    Mat2      Des2     (No data)  (No data)
    The required output is :
    Matnr     Descr    Column4
    Mat1      Des1     sfsfs
    Mat2      Des2     (No data)
    How to do this in the most simplest / right way?
    Hope my question is clear .
    Thanking you in advance,
    Shankar

    Hi shankara,
    1. In the output we want to hide those columns
    For this,
      a) first we have to know/detect  by looping the table/logic
         that which fields contain no data / are to be hidden
       b) after that we have to use the field catalogue properties.
        c) We have to loop at the fieldcatalogue,
            and set the value fieldcat-NO_OUT = 'X'.
           for those fields.
        (In this manner, those fields/columns won't be shown)
    regards,
    amit m.

  • How to hide table column based on country molga value

    Hi Experts,
    I am doing some enhancement in ess application. I want to hide table column based on country code i.e. Molga value.
    I want to hide coulm for only Japan country reset of them i need to be show those coulmn.
    Could you please provide me a sample code.
    Regards
    Chakri

    Hi Chakri,
    Your setting the table value that time you will get the Country Code.
    1.Create the attribute like Country_Column_Visible Data Type bind the com.sap.ide.webdynpro.uielementdefinitions.Visibility this value  you need to bind the table country column.
    2.In Table You need to check the country code Japan is available you need follow this below sample code.
    for(int i=0;i<tablesize;i++)
         tablesithValue=wdContext.nodeTable().getTablenode(i);
         if(null != tablesithValue.getcountrycode)
         if(tablesithValue.getcountrycode.equalsIgnoreCase("Japan"))
              wdContext.currentxxxxElement.setCountry_Column_Visible(WDVisibility.NONE);
         }else
              wdContext.currentxxxxElement.setCountry_Column_Visible(WDVisibility.VISIBLE);
    Use the above code you condition it will work.I hope it will help you.
    BR,
    Durga

  • How to hide ALV column in webdynpro

    Hi frnds,
                   I want to hide one columns in ALV output on webdynpro , give the procedure ...
    Thanks & Regards,
    Rajesh.j

    Procedure is :
    a) Get ALV Model reference
    b) Get list of ALV Columns
    c) Loop at each column and set visibility
    Code would be something like this
    I'm storing ALV model reference in view attributes wd_this->alv_config_table of type ref to CL_SALV_WD_CONFIG_TABLE.
    Data: lo_cmp_usage type ref to if_wd_component_usage.
      DATA: lr_salv_wd_table TYPE REF TO iwci_salv_wd_table.
      DATA: lr_column_settings TYPE REF TO if_salv_wd_column_settings,
            lr_column          TYPE REF TO cl_salv_wd_column,
            lt_column type salv_wd_t_column_ref,
            ls_column type salv_wd_s_column_ref.
    *create an instance of ALV component
      lo_cmp_usage =   wd_this->wd_cpuse_OVERVIEW_EARNED_ALV( ).
    * if not initialized, then initialize
      if lo_cmp_usage->has_active_component( ) is initial.
        lo_cmp_usage->create_component( ).
      endif.
    * get ALV component
      lr_salv_wd_table = wd_this->wd_cpifc_OVERVIEW_EARNED_ALV( ).
       wd_this->alv_config_table = lr_salv_wd_table->get_model( ).
      lr_column_settings ?= wd_this->alv_config_table.
      lt_column = lr_column_settings->get_columns( ).
      loop at lt_column into ls_column.
        CASE ls_column-id.
          when 'POST_YEAR'.
            ls_column-r_column->set_visible( if_wdl_core=>visibility_none ).
       ENDCASE.
    endloop.

  • Hide the column from ssrs report

    Hello,
    I am creating matrix report , I want to hide the column in which Data Field is null. I did tried by writing this expression
    =IIF(IsNothing((Fields!test_name.Value,
    "matrix1_category")),true,false)
    but problem with this expression is it hide the column on first page,It does not do it on rest of the pages, I have multiple pages grouped on one column and added page break on that group.
    Please give me some solution
    Column 1 -ChildGroup-> Column 2 -ChildGroup-> Coulmn 3  | Column 4 |
        |
    Data      |
    Added Page Break on Column 1 and Column 2
    Thank-you!

    Hi Piyush,
    If I understand correctly, you want to hide the entire column, when it has NULL value of the specify field. We can configure the Column Visibility.
    Please refer to the following steps:
    1. Right click the column, select Column Visibility option.
    2. Select “Show or hide based on an expression” with above expression.
    If there are any misunderstanding, please feel free to let me know.
    Regards,
    Alisa Tang
    Alisa Tang
    TechNet Community Support

  • RE: Hide a column in web report using table interface class

    Hi,
    I want to hide first column in web template using table interface class. Following is the code i used in CAPTION_CELL and CHARACTERISTIC_CELL. Is this correct?
    method CAPTION_CELL.
    *First column
    if i_x = 1.
    add comment tag
    move '<!-- ' to C_CELL_CONTENT.
    endif.
    endmethod.
    method CHARACTERISTIC_CELL
    First column
    if i_x = 1.
    save start-time column
    move I_CHAVL_EXT to L_STARTTIME.
    add comment tag
    move '<!-- ' to C_CELL_CONTENT.
    endif.
    endmethod.
    When i execute the web template it is still displaying the first column. Do i have to code in any other method?
    Thank you,
    Mala Venkatesh

    Hi , the implementation should look like...
    method CAPTION_CELL .
    *CALL METHOD SUPER->CAPTION_CELL
    EXPORTING
    I_X =
    I_Y =
    I_IS_EMPTY =
    I_IOBJNM_ROW =
    I_ATTRINM_ROW =
    I_TEXT_ROW =
    I_IOBJNM_COLUMN =
    I_ATTRINM_COLUMN =
    I_TEXT_COLUMN =
    I_IS_REPETITION =
    I_COLSPAN =
    I_ROWSPAN =
    CHANGING
    C_CELL_ID =
    C_CELL_CONTENT =
    C_CELL_STYLE =
    C_CELL_TD_EXTEND =
    First column
    if i_x = 1.
    add comment tag
    move '<!-- ' to C_CELL_CONTENT.
    endif.
    Second column
    if i_x = 2.
    close comment tag
    concatenate '--> '
    C_CELL_CONTENT
    into C_CELL_CONTENT.
    endif.
    endmethod.
    method CHARACTERISTIC_CELL .
    *CALL METHOD SUPER->CHARACTERISTIC_CELL
    EXPORTING
    I_X =
    I_Y =
    I_IOBJNM =
    I_AXIS =
    I_CHAVL_EXT =
    I_CHAVL =
    I_NODE_IOBJNM =
    I_TEXT =
    I_HRY_ACTIVE =
    I_DRILLSTATE =
    I_DISPLAY_LEVEL =
    I_USE_TEXT =
    I_IS_SUM =
    I_IS_REPETITION =
    I_FIRST_CELL = RS_C_FALSE
    I_LAST_CELL = RS_C_FALSE
    I_CELLSPAN =
    I_CELLSPAN_ORT =
    CHANGING
    C_CELL_ID =
    C_CELL_CONTENT =
    C_CELL_STYLE =
    C_CELL_TD_EXTEND =
    First column
    if i_x = 1.
    save document-item number
    move I_CHAVL_EXT to l_docitem.
    add comment tag
    move '<!-- ' to C_CELL_CONTENT.
    endif.
    Second column
    if i_x = 2.
    close comment tag
    concatenate '--> '
    C_CELL_CONTENT
    l_docitem
    into C_CELL_CONTENT
    separated by space.
    endif.
    endmethod.
    Activate the methods/class and add this in the Web Template!
    for example:
    <param name="MODIFY_CLASS" value="ZHCOLAPP">
    ZHCOLAPP is the table interface class in this case.
    Best,
    Michael

  • How to hide multiple columns in multicolumn listbox like as an excel sheet?

    Hello All,
    I have large amount of data that is to be displayed on multicolumn listbox. After displaying that, I want to hide or delete some columns from listbox in runtime.
    I know how to hide one column using active cell property node. But I want to hide multiple columns. I am using LabVIEW 2011. 
    Thanks in advance.
    Thanks & Regards,
    Manisha

    Thank you so much. 
    But I have total 12 columns and I don't want to delete columns serially. I want to delete inbetween columns, like in attached VI I want to delete column A & D only. 
    And in this user have to select it from frontpanel. I want this is to be done as in excel, like we select the entire column and either we hide it or delete it. One more thing I want to clear the data in multicolumn when I next time open my VI. How to do that?
    I hope am clear in explaining my problem.
    Thanks & Regards,
    Manisha
    Attachments:
    Delete Column.vi ‏10 KB

  • Hide the column

    Hi,
    Is it  possible to hide column when there is no value not even zero?
    Regards,
    Pooja.

    Hi
    I think you want to hide a column only when there is no values
    So you like to display the column when it has values
    If this is the case, you can do this with the help of macro
    Macros are VBA codes written in the excel sheet. To write, go to the botoom pane of the excel sheet-> right click -? view code...there you have write the code
    You can write a code with the logic.....hide column/remove column when all values are zero
    Or you just want to hide the column even if it has values ......just right click -> always hide the key figure in the Bex query designer
    Assign points if useful
    Regards
    N Ganesh

Maybe you are looking for