Showing of hide columns in JTable.

Hi,
In my Application,The requirement is the user can remove some columns.After that the user can select the columns that he required from the list of all columns.
The user can select already removed column.How can I show the already removed columns?
I am removing columns like this.
int [] col = table.getColumnModel().getSelectedColumns();
table.getColumnModel().removeColumn(table.getColumnModel().getColumn(col[0]));
Please help me getting removed columns.I have to show the columns from the list the user has selected.
Thanks in Advance.
Vattikuti

Hi,
Save your column somewhere before remove it (with table.getColumnModel().getColumn(int) ). And when the user want to show the hidden column, add it to the table with table.getColumnModel().addColumn(TableColumn).
Hope it help you.
Fade.

Similar Messages

  • Show and hide columns.

    I have a rather large JTable with a lot of columns that are updated once in a while.
    Is there an easy way to show and hide columns, so that I don't have to keep track on which a shown and hide when I use setValueAt()...?

    JTable does the conversion between the column indexes of the view and the model.
    You should be able to add remove columns using addColumn and removeColumn methods. and in the TableColumn class you can specify the coulmn in the model that the TableColumn refers to.

  • Show/hide a column  in JTable

    I want to show/hide columns in JTable
    How is this possible
    Note that columns that are hidden may be showed later
    thanks in advance
    Renjith

    I tried out for this:TableColumn col = jTable.getColumnModel().getColumn( colnum );
    if( col != null )
      col.setPreferredWidth( 0 );
      col.setMaxWidth( 0 );
    }But the column seems to have minimum width which you can't even change with col.setMinWidth( 0 );

  • Show/hide column

    How to show or hide column within ADF table based on certain condition ?

    http://www.oracle.com/technetwork/developer-tools/adf/learnmore/84-treetable-column-hide-show-404584.pdf
    https://forums.oracle.com/thread/2275114

  • Hiding a column in jtable made from DefaultTableModel.

    I have made my jtable from DefaultTableModel.
    I want to keep one column in the jtable as hidden storing some data containing neccessary information like the "path of the file"
    which need not be shown to the user.
    Please tell me how I can hide one column in the Jtable.
    please provide siome link or code for the same.
    Tia,
    Sarwa

    dayanandabv wrote:
    [http://search.sun.com/search/onesearch/index.jsp?qt=hide+column%2B+JTable&rfsubcat=&col=developer-forums]
    My thought exactly.
    db

  • Problem with Hiding Columns in JTable

    Hi.
    Who knows how to hide column in JTable.
    I try to get column:
    MyTab.getColumnModel().getColumn(i)But there is no methods like SetVisible(false)
    What to DO???

    http://www.google.com/search?hl=en&q=%2Bhide+%2Bcolumn+%2Bjtable&btnG=Google+Search

  • How to show or Hide Generic Column in a regular report

    Hi All,
    I have created report based on "SQL query (pl/sql function body returning sql query). It returns columns based on some conditions. I have total 60 generic columns like (COL1,COL2....COL60) but it returns 18 or 20 columns based on my conditions, how can I hide the columns that I don't needed. My column heading is based on function return by ':' separated. My function returns number of columns also. Is there any we I can show only those columns which contains data. My report is exactly similar to the default "SQL query (pl/sql function body returning sql query). I didn't find any logic how they are doing this show and hide. I appreciate any ones help.
    Thanks,

    Hi there,
    Somehow you need to find out how many columns your dynamic select will return (by what you said it seems that your procedure returns this information). Then store that number in a hidden page item, say Pnn_COUNT.
    Then, for the 19th and 20th columns in the report add these conditions:
    Column 19: :Pnn_COUNT >= 19
    Column 20: :Pnn_COUNT >= 20
    I hope this helps.
    Luis

  • How to make a layer from the ADF pivot table invisible , show-hide column-row-data

    Hello all ,
    I need to create a pivottable with ADF 12c for reporting purposes.
    I have a table or view with 10 items of type VARCHAR2 , C1,C2,C3,C4,C5,C6,C7,C8,C9,C10  and   10 items of type NUMBER N1,N2,N3,N4,N5,N6,N7,N8,N9,N10
    The items of type VARCHAR2 are for Column and Row areas and the items NUMBER are for Data Areas
    I want to create a jsf page with one empty pivottable and in code Show or Hide the items in the Column area , Row area , Data area
    Con you send me a small sample ?
    I test with this code that i find in oracle OTN but not work.
    <dvt:pivotTable id="pt2" value="#{bindings.WebPivotDataView1.pivotTableModel}" var="cellData"
    varStatus="cellStatus" splitMode="enabled"
    binding="#{backingBeanScope.CmfPivotBean.pivotTable}"
    >
    <dvt:headerCell>
    <af:switcher facetName="#{cellData.layerName}" defaultFacet="Default" id="s1">
    <f:facet name="DataLayer">
    <af:outputText value="#{cellData.label}" id="ot1"/>
    </f:facet>
    <f:facet name="C01">
    <af:outputText value="#{cellData.dataValue}" id="ot2"/>
    </f:facet>
    <f:facet name="Default">
    <af:outputText value="#{cellData.dataValue}" id="ot3"/>
    </f:facet>
    </af:switcher>
    </dvt:headerCell>
    <dvt:dataCell>
    <af:switcher facetName="#{cellStatus.members.DataLayer.value}" defaultFacet="Default" id="s2">
    <f:facet name="N01">
    <af:outputText value="#{cellData.dataValue}" id="ot4">
    <af:convertNumber groupingUsed="false"
    pattern="#{bindings.WebPivotDataView1.hints.N01.format}"/>
    </af:outputText>
    </f:facet>
    <f:facet name="Default">
    <af:outputText value="#{cellData.dataValue}" id="ot5"/>
    </f:facet>
    </af:switcher>
    </dvt:dataCell>
    </dvt:pivotTable>
    DCBindingContainer bindingContainer = (DCBindingContainer)ADFContext.getCurrent().getRequestScope().get("bindings");
    CubicBinding cubicBinding = (CubicBinding)bindingContainer.findCtrlBinding("WebPivotDataView1");
    CubicEditor cubicEditor = cubicBinding.getCubicEditor();
    cubicEditor.removeLayer(DataDirector.ROW_EDGE, 0); //remove 1st row edge
    cubicEditor.removeLayer(DataDirector.COLUMN_EDGE, 0); // remove 1st column edge
    cubicEditor.removeDataItem(0);
    CubicDefinition def;
    def = cubicBinding.getProjection();
    LayerDefinition layerDefinition = new LayerDefinition("C3");
    cubicEditor.addLayer(DataDirector.ROW_EDGE, 0, layerDefinition);    
    LayerDefinition layerDefinition2 = new LayerDefinition("C4");
    cubicEditor.addLayer(DataDirector.COLUMN_EDGE, 0, layerDefinition2);
    DataItemDefinition def3 = new DataItemDefinition("N1");
    cubicEditor.addDataItem(def3);
    AdfFacesContext.getCurrentInstance().addPartialTarget(pivotTable);
    Can you help me if is possible to create a pivottable binding to a one ViewObject and in code show/hide or compose the layout of the pivottable ??
    I search in google and OTN oracle and not find any code.
    Only find the code of the samples that is very complex for me , the code of the samples create the PivotTableModel from one Array , and i want to binding from one ADB BC ViewObject.
    Thanks in advance

    The solution I presented for your use case an DOAG 2013 was to create a pivot table binding out of user defined attributes from the table. For the defined attributes a VO is dynamically created as well as the pivot binding. The pivot binding is then exchanged at runtime together with the activation of the dynamic VO needed to only get the data needed for the particularly pivot table.
    Your solution using the CubicEditor is hard to implement due to the missing documentation. This was the reason I did not follow this approach, However it's not impossible (done it on a very small scale).
    None of the solution are what I call simple. They are complicated, complex and in part not supported solution (exchanging the pivot table binding at runtime need to use internal classes, which is not supported).
    I can't give you a working sample as it's too complex. I can make the slides available, however they are in German.
    Timo

  • Show or Hide the icons in a report column in APEX

    Hi All,
    I have a requirement to show or Hide a Delete Icon in my report.
    Condition is whenever the transfer is completed, then the user should not see the Delete Icon for that particular row of the report. I.E. for example if there are 5 rows in the report, and for 2 rows the value of the Transfer is NULL, then the Delete icon should be appear to the user. If the value for the column transfer is Not Null for remaining 3 rows, then the user should not be able to see the Delete Icon.
    For this I did like below,
    In the report, I edited the Del_Icon and Selected 'Value of the Item/Column in Expression1 is NULL' and entered 'Transferred' in Expression1 in Conditional Display area. But even if the value for Transfer column is 'Transferred', the Delete Icon is still appearing for that row.
    Can someone please let me know where can be the mistake is?
    Please let me know if you require more info.
    Actually in the application if we go to Transfer Page, there is an option to create a row for Transfer page. There is a column Transfer, If we do not enter any value for the column Transfer and submit the page, the record will be created and the Delete Icon should be appear. If I update the row in the application and provide some value, and click submit button, then the Delete Icon should not appear.
    Edited by: 980540 on Apr 2, 2013 5:08 AM

    You can do one thing, check the condition in the report sql itself and display the image
    select case
                when transfer is null then '<a onclick="f_func()"><img src="#APP_IMAGES#img"></a>'
                else null
                end col1,
             col2
    from tableI have used "APP_IMAGES" you can changes it accordingly.
    and the <a> tag should be like this *<a onclick="f_func()"*
    in the javascript function you can submit the page using apex.submit('REQUEST') and condition your delete process on the REQUEST.
    Regards,
    Tauceef

  • 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.

  • How can i make hidden column in JTable

    hi, how can i make hidden column in JTable,
    basically i have a ID field in JTable, i have to use this ID , but i also dont want to show this ID in JTable.
    any idea how ??

    staiji its not working
    i did this :
    first :
    TableColumnModel columnModel =
    usersTable.getColumnModel();TableColumn column =
    columnModel.getColumn(1);
    usersTable.removeColumn(column);
    then when i trying to get this :
    Integer userId =
    (Integer)usersTable.getValueAt(UserBrowser.this.usersTa
    le.getSelectedRow(), 0);
    it not give me ID column's value .
    i have a column in JTable like :
    ID | Username | First name | Last name
    i want to hide ID column , but get this ID's value
    when user clicks on JTable row.Hi, if you would read the documentation about JTable.getValueAt(...) you will find, that there is a significant difference between this method and the datamodels getValueAt(...) method. JTables getValueAt(...) method interprets column-index as index in its TableColumnModel - in your TableColumnModel there is no column any longer that holds ID values, therefore you were not able to get it by JTable.getValueAt(...). Do not use these methods for the purpose you want it for - you will also get the wrong values, if the user has repositioned columns - the column index is always interpreted as index in the currently used TableColumnModel and IS NOT A MODELINDEX.
    greetings Marsian

  • Hide column in the adress if it is null and print next line in XML publishe

    Hi,
    I'm converting oracle report to XML publisher report.
    I craeted template rtf with word. everything works fine.
    Except address prints null coumns if it is null.
    I used if condition in template. something like this...
    <?if:B_ADDRESS1!=''?><?B_ADDRESS1?><?end if?>
    But I see still it prints null columns.
    Any body have idea how can i fix this?
    Thanks
    pallavi

    Hi Guys,
    I have built a template for FSG reports. Currently the FSG Reports when run in XML does pull the Display Sets definition for the report. The Display Set is used to hide certain row and Column intersections from the FSG.
    So to accomplish this I have coded each column in the template to display data or hide data for a particular row by using the code
    <?if:(position()) !=1?><?fsg:RptCell[2]?><?end if?> ------ This means, show the column for all rows except row 1.
    Now there are some places I have to hide Column 1 for row 2 and row3 and display for row 1 and row 4.
    Can anyone please tell me how I can accomplish this.
    Thanks

  • How to hide columns in each page of SSRS report for grouped tablix

    Hello all,
    I have a requirement like when SSRS report (used row grouping)is exported to EXCEL
    1)  Each report page should be exported to a separate excel sheet
    2) Each sheet will have different columns (that is some columns will hide in sheet2, sheet3...)
    3) Eg: If a country report is there with details like country name, country code, currency code. Now each country details should export to separate excel sheet and sheet 1 should show Country Name and Country code; Sheet2 should show: Country Code, Currency
    Code; Sheet3 should show: Country Name, Country Code, Currency Code.
    I am done with point#1 above: Each report page should be exported to a separate excel sheet. Can some one help on point#2:Each sheet will have different columns (that is some columns will hide in sheet2, sheet3...)
    Thanks,
    Paandey : Dont forget to mark it as Answered if found useful

    Hi paandey,
    According to your description, there are three columns named country name, country code, currency code in the report. When export the report to excel, you want to show Country Name and Country code in sheet1, Country Code and Currency Code in sheet2, and
    show all of the three columns in sheet3.
    In Reporting Services, we couldn’t achieve your goal by setting visibility of columns in one tablix. As a workaround, we can use three tablix in the report, then add page break to the tablix. For detail information, please refer to the following steps:
     1. Since you have created a tablix with three column, copy and paste it to the report twice.
     2. Right-click column handle of Currency code in tablix1, click Column Visibility.
     3. Check Show or hide based on an expression, click (fx) button, then type the expression:
    =(Globals!RenderFormat.Name = “EXCELOPENXML”)
     4. Right-click column handle of Country name in tablix2, set its visibility like step3 above.
     5. Select and right-click tablix2, click Tablix Properties.
     6. In General pane, in Page Break Options section, check Add a page break before check box.
     7. Click Visibility in left pane, check Show or hide based on an expression, click (fx) button, then type the expression:
    =(Globals!RenderFormat.Name <> “EXCELOPENXML”)
     8. Select and right-click tablix3, add page break to it like step6 above.
     9. Set its visibility like step7 above.
    The following screenshot is for your reference:
    For more information, please refer to the following document:
    http://blogs.msdn.com/b/robertbruckner/archive/2010/05/16/report-design-naming-excel-worksheets.aspx
    If you have any more questions, please feel free to ask.
    Best Regards,
    Wendy Fu

  • Show only specific columns

    hello,
    using obiee 11g
    I have a requirement like this
    I have 2 prompts, begin date and close date as prompts,Depending upon the date selected i want to show or hide the column.
    By default i made the prompts to show current date and current_date-365
    And also the column header and the data shows properly for the column.
    My only problem is if i select the date as
    01/01/2011 to 30/07/2011 it should show only 7 months data so should show only 7 columns and hide rest 5 columns.
    Its showing from jan to Dec and I want it to show only jan to july?
    Is this possible is my question?
    Thanks

    Hello Deepak,
    Went through the Article,
    I created a filter report which has 2 columns and 1 row->Start And End Date.
    More info on my req--->
    Actually my data is in column wise and not row wise,i.e. my columns are dynamic,headings are start date as col1 and .....and show start date+12 as the last column.
    I have 12 columns in the main report whose header i am taking from the prompt values because i want the header to be dynamic depending upon the date selected.
    So in that prompt i have 12 variables for each 1 headings.So first variable will have the value like startdate prompt and then next variable will have startdate+1.
    In the column formula for each column i am using a filter function to filter the measure column depending
    the month and year of the table.date
    is equal to
    the month and year of the start date prompt.
    So in the main report if i add a filter based on another request,since i have the data as column, no effect its showing.
    Thanks

  • Add and remove columns from JTable

    Help me please!
    A try to remove column from JTable. It's removed, but when I try to add column in table, then I get all old (removed early) columns + new column....
    I completely confused with it.....
    Here is my code for remove column:
    class DelC implements ActionListener
              public void actionPerformed (ActionEvent e )
                   int [] HowManyColDelete = table.getSelectedColumns();
                   if (HowManyColDelete.length !=0)
                        TableColumnModel tableCModel = table.getColumnModel();
                        for (int i = HowManyColDelete.length-1; i>-1; i--)
                             table.getColumnModel().removeColumn (tableCModel.getColumn (HowManyColDelete [ i ]));
                   else
                          JOptionPane.showMessageDialog(JOptionPane.getRootFrame(), "Column is not selected!");
         }

    It's little ex for me, I just try understand clearly how it's work (table models i mean). Here is code. All action with tables take place through menu items.
    My brain is boiled, I've try a lot of variants of code, but did't get right result :((
    It's code represent problem, which I've describe above. If you'll try remove column and then add it again, it will be ma-a-a-any colunms...
    I understand, that my code just hide columns, not delete from table model....
    But now I have not any decision of my problem...
    Thanks a lot for any help. :)
    import javax.swing.*;
    import java.awt.*;
    import javax.swing.table.*;
    import java.awt.event.*;
    import javax.swing.table.DefaultTableModel;
    class JTableF extends JFrame
         Object [] [] data = new Object [0] [2];
         JTable table;
         DefaultTableModel model;
         String [] columnNames = {"1", "2"};
         TableColumnModel cm;
         JTableF()
              super("Table features");
              setDefaultLookAndFeelDecorated( true );
              setDefaultCloseOperation (JFrame.EXIT_ON_CLOSE);
              JMenuBar MBar = new JMenuBar();
              JMenu [] menus =  {new JMenu("A"), new JMenu("B")};
              JMenuItem [] menu1 =  {new JMenuItem("Add row"), new JMenuItem("Delete row", 'D'),  new JMenuItem("Add column"), new JMenuItem("Delete column")};
              menu1 [ 0 ].addActionListener(new AddL());
              menu1 [ 1 ].addActionListener(new DelL());
              menu1 [ 2 ].addActionListener(new AddC());
              menu1 [ 3 ].addActionListener(new DelC());
              for (int i=0; i<menu1.length; i++)
                   menus [ 0 ].add( menu1 [ i ]);
              for (int i=0; i<menus.length; i++)
                   MBar.add(menus );
              JPanel panel = new JPanel ();
              model = new DefaultTableModel( data, columnNames );
              table = new JTable (model);
              cm = table.getColumnModel();
              panel.add (new JScrollPane(table));
              JButton b = new JButton ("Add row button");
              b.addActionListener(new AddL());
              panel.add (b);
              setJMenuBar (MBar);
              getContentPane().add(panel);
              pack();
              setLocationRelativeTo (null);
              setVisible (true);
         class DelC implements ActionListener
              public void actionPerformed (ActionEvent e )
                   int [] HowManyColDelete = table.getSelectedColumns();
                   if (HowManyColDelete.length !=0)
                        TableColumnModel tableCModel = table.getColumnModel();
                        for (int i = HowManyColDelete.length-1; i>-1; i--)
                             int vizibleCol = table.convertColumnIndexToView(HowManyColDelete [ i ]);
                             tableCModel.removeColumn (tableCModel.getColumn (vizibleCol));
                        //cm = tableCModel;
                   else
                        JOptionPane.showMessageDialog(JOptionPane.getRootFrame(), "Column is not selected!");
         class AddC implements ActionListener
              public void actionPerformed (ActionEvent e)
                   //table.setColumnModel(cm);
                   Object NewColumnName = new String();
                   NewColumnName = JOptionPane.showInputDialog ("Input new column name", "Here");
                   int i = model.getRowCount();
                   int j = model.getColumnCount();
                   Object [] newData = new Object [ i ];
                   model.addColumn ( NewColumnName, newData);
         class AddL implements ActionListener
              public void actionPerformed (ActionEvent e)
                   int i = model.getColumnCount();
                   Object [] Row = new Object [ i ];
                   model.addRow ( Row );
         class DelL implements ActionListener
              public void actionPerformed (ActionEvent e)
                   int [] HowManyRowsDelete = table.getSelectedRows();
                   if (HowManyRowsDelete.length !=0)
                        for (int k = HowManyRowsDelete.length-1; k>-1; k--)
                             model.removeRow (HowManyRowsDelete[k]);
                   else
                        JOptionPane.showMessageDialog(JOptionPane.getRootFrame(), "Row is not selected!");
         public static void main (String [] args)
              javax.swing.SwingUtilities.invokeLater(new Runnable()
                   public void run()
                        JTableF inst = new JTableF();

Maybe you are looking for

  • Problem while generating Update progam for a Change Document Object

    Hi, I'm trying to deal with Change Document concept in a R/3 4.6C environment and to establish new Change Document object for my (Z)-table. I haven't using any namespace and created object with name ZTEST. Following the online documentation I came to

  • Won't allow me to install.

    I tried to re-install Firefox and not it won't let me open the file. It asks which program I want to open it with and it won't let me start. == This happened == Every time Firefox opened == I deleted it.

  • Image preview in Open dialog window (Photoshop CS6)

    Hi We had a possibility to see images preview in Open File dialog window of Photoshop CS5 but in new CS6 version there is not such possibility. Should I forget about that nice option and use Mini Bridge?

  • Itunes won't install as it says it's an unsafe programme

    It downloads the says delete as its unsafe programme. Driving me insane. Have unistalled itunes because I couldnt update as signiture issues so just want to install it from scratch. Please help. Very frustrated. Thanks Graham

  • Unable to check for Downloads

    I rented a movie a couple of days ago, still not in in "downloads..?" I get the "Unable to check for dowloads" message each time I try. I have since purchased two movies and rented another without any issues. ANY IDEAS? THanks