JTable + add column

hey all!!
i have posted this post
http://forum.java.sun.com/thread.jspa?threadID=5218799
previously and as you can read there everything worked out ok.
well now i have another, similar problem. now i know how to dispaly boolean values, in a table, as a check box. what i would like to do now is to select from database lets say
first name, last name show the names in a table and then add a column what would be again a check box and the header would say 'delete?'. if user ticks the check box then on a button press i would get and delete the data that is marked as to be deleted.
i have worked out how to add a clumn, set the header value but now i do not know how to get the check box in there. the advice i got in the previous post can be used for data that si being extracted from a database and check box can be show with getColumnClass() method. but how to go about showing a check box in a column that has been added to already existing ResultSet??
anybody any suggestions, thoughts,links to tuts, or sample code??
thanks
v.v

hey all!!
i have posted this post
http://forum.java.sun.com/thread.jspa?threadID=5218799
previously and as you can read there everything worked out ok.
well now i have another, similar problem. now i know how to dispaly boolean values, in a table, as a check box. what i would like to do now is to select from database lets say
first name, last name show the names in a table and then add a column what would be again a check box and the header would say 'delete?'. if user ticks the check box then on a button press i would get and delete the data that is marked as to be deleted.
i have worked out how to add a clumn, set the header value but now i do not know how to get the check box in there. the advice i got in the previous post can be used for data that si being extracted from a database and check box can be show with getColumnClass() method. but how to go about showing a check box in a column that has been added to already existing ResultSet??
anybody any suggestions, thoughts,links to tuts, or sample code??
thanks
v.v

Similar Messages

  • JTable Header & column Headers

    i want to add a table Header(Level 1 Students)
    and a columns Headers(Name ID Section#)
    How can i do that ?
    Thanks a lot
    This is my code:
    import java.awt.*;
    import java.applet.*;
    import java.applet.Applet;
    import java.awt.image.*;
    import javax.swing.*;
    import java.util.*;
    class DrawingCanvas extends Canvas{
    Applet app;
    Image img;
    public void init(Applet app)
         setBackground(new Color(165, 215, 220));
         this.app=app;
         img = app.getImage(app.getCodeBase(), "cloud.gif");
    public void paint(Graphics g)
         g.drawImage(img,50,50,this);
    public class Table_Button extends JApplet {
         DrawingCanvas canvas;
         // a separate JPanel is associated with each JButton
    JPanel button1_JPanel, button2_JPanel, button3_JPanel, button4_JPanel,button5_JPanel,button6_JPanel,button7_JPanel;
    JPanel button8_JPanel;
    JPanel topic;     //For Topic name
    JPanel JButtons; // for all the JButtons
    JPanel tables_JButtons_JPanel;
    JTable table;
    JButton button1,button2,button3,button4,button5,button6,button7;
    JButton show_button8;
    public void init(){
    canvas = new DrawingCanvas();
    canvas.init(this);
    //Controls JButtons
         button1 = new JButton("button1");
    button2 = new JButton("button2");
    button3 = new JButton("button3");
    button4 = new JButton("button4");
    button5= new JButton("button5");
    button6= new JButton("button6");
    button7= new JButton ("button7");
    //button8 JButton
    show_button8= new JButton("Show button8");
    button1.setBackground(new Color(111, 178, 230));
    button2.setBackground(new Color(111, 178, 230));
    button3.setBackground(new Color(111, 178, 230));
    button4.setBackground(new Color(111, 178, 230));
    button5.setBackground(new Color(111, 178, 230));
    button6.setBackground(new Color(111, 178, 230));
    button7.setBackground(new Color(111, 178, 230));
    show_button8.setBackground(new Color(111, 178, 230));
    /*Topic Name*/
    topic = new JPanel();
    topic.setLayout(new BorderLayout());
    topic.add(new JLabel(" Topic Name ",JLabel.CENTER));
    All Controls
    /*JButtons*/
         button1_JPanel = new JPanel();
    button1_JPanel.setLayout(new BorderLayout());
    button1_JPanel.add(button1);
    button2_JPanel = new JPanel();
    button2_JPanel.setLayout(new BorderLayout());
    button2_JPanel.add(button2);
    button3_JPanel = new JPanel();
    button3_JPanel.setLayout(new BorderLayout());
    button3_JPanel.add(button3);
    button4_JPanel = new JPanel();
    button4_JPanel.setLayout(new BorderLayout());
    button4_JPanel.add(button4);
    button5_JPanel = new JPanel();
    button5_JPanel.setLayout(new BorderLayout());
    button5_JPanel.add(button5);
    button6_JPanel = new JPanel();
    button6_JPanel.setLayout(new BorderLayout());
    button6_JPanel.add(button6);
    button7_JPanel = new JPanel();
    button7_JPanel.setLayout(new BorderLayout());
    button7_JPanel.add(button7);
    button8_JPanel = new JPanel();
    button8_JPanel.setLayout(new BorderLayout());
    button8_JPanel.add(show_button8);
    // all JButtons JPanel
    JButtons = new JPanel();
    JButtons.setLayout(new FlowLayout());
    JButtons.setBackground(new Color(228, 241, 250));
    JButtons.add(button1_JPanel);
    JButtons.add(button2_JPanel);
    JButtons.add(button3_JPanel);
    JButtons.add(button4_JPanel);
    JButtons.add(button5_JPanel);
    JButtons.add(button6_JPanel);
    JButtons.add(button7_JPanel);
    JButtons.add(button8_JPanel);
    //How to set the table header(title) to (Level 1 Students)
    // How to set the table columns headers to (Name ID Section)
         table = new JTable( 5, 3 );
         tables_JButtons_JPanel = new JPanel();
    tables_JButtons_JPanel.setLayout(new BorderLayout());
    tables_JButtons_JPanel.add("North",table);
    tables_JButtons_JPanel.add("South",JButtons);
    // Display the JPanels..
         this.setLayout(new BorderLayout());     
    add("North",topic);
    add("Center",canvas); // here i want to add some images and drawings
    add("South",tables_JButtons_JPanel);
    }// end inti()
    }

    JTable Tutorial didn't specify how to add columns names when using the constructor:
    JTable(int numberofRows,int numberofColumns) Well then use another constructor. For example:
    DefaultTableModel model = new DefaultTableModel(...);
    JTable table = new JTable( model );Also, I forgot to mention don't use AWT components in a Swing application. Canvas is an AWT component. Use JPanel instead.

  • JTable (dynamic columns)

    Well guys, voil� my problem...
    I've a Person class, who has some methods to get the person information, like getName(), getAge(), getAdresse(), etc... I would display the information of all the persons in the diary in a JTable... Ok, it's all right, i made a class who extends AbstractModelTable, overriding the getValueAt(int, int) with a switch:
    // private static final int COLUMN_NAME = 0;
    // private static final int COLUMN_NAME = 1;
    switch (column) {
            case COLUMN_NAME:
                  return cols[rowIndex].getName();
             case COLUMN_AGE:
                   return cols[rowIndex].getAge();
              default:
                    return;
    }The code it's something like that... I'm sorry i don't show the code, i've not the source here!
    It works very fine!... But now, i want to let the user choose witch columns to display...
    I made a lot of tries, but i could not get the solution... The only one thing I could, was to eliminate the columns with zero value in the conf file, but the headers were not in the correct order!... And there's another problem too, when I switch the columnIndex, if it equals to COLUMN_EMAIL = 15 means that JTree is getting the value of the 15th column, but if the user had removed the 2 column for example, the 15th column is not more the email column, it's the 15+1 columns :S... is it clair? I think it's a little difficult to explain, and as you see, i don't speak english very well :P...
    Summary: I would create a class extending JTable with columns configurables, i mean, let the user choose witch columns should be showed... Any idea ?... I can avoid the JTable component, so If you've another solution, it will be ok...
    Greetings and thank you guys...

    Your requirement is very general so we can't give you an exact solution, but I can try explaining how JTable works.
    The TableModel is used to store the data. The JTable is used to display the data. When a table is first created using a TableModel a TableColumnModel is created. Each TableColumn in the TableColumnModel maps directly to a column in the TableModel.
    Now what happens if the user moves column 15 to the first column in the table? The data hasn't changed, only the view of the data has changed. So even though the column is in column 0 of the table, the data must still come from column 15 in the TableModel. The TableColumns of the TableColumnModel do the mapping for you so you don't need to worry about the reordering of columns.
    However, if you have some code in your program that accesses the data directly, then you need to be aware of this situation. Fortunately JTable has some methods to make this mapping easy.
    table.getValueAt(...) will get data from the requested column in the view of the table
    table.getModel().getValueAt(...) will get data form the requested column in the TableModel.
    You can also do the mapping between "view" and "model" columns using the methods:
    table.convertColumnIndexToModel(...)
    table.convertColumnIndexToView(...) So what does this mean with dynamic columns? Well, you would build your table normally, then you would remove the TableColumns from the TableColumnModel that the user does not want to see.
    The following example is so code I wrote a while ago that will help in manipulating the TableColumnModel. Right click on the TableHeader to see the visible/hidden status of each column:
    import java.awt.*;
    import java.util.*;
    import java.awt.event.*;
    import javax.swing.*;
    import javax.swing.table.*;
    public class TableColumnManager implements MouseListener, ActionListener
         private static final String HIDDEN_COLUMN = "HiddenColumn:";
         //  Reference to the Singleton instance of this class
         private static TableColumnManager singleton;
         *  Use a private constructor so we can create a Singleton.
         private TableColumnManager()
         *  Get the Singleton instance of the <code>TableColumnManager</code>.
         *  @return  the Singlton instance of <code>TableColumnManager</code>
         private static TableColumnManager getInstance()
              if (singleton == null)
                   singleton = new TableColumnManager();
              return singleton;
         *  Add support for the management of visible <code>TableColumns</code>
         *  for a given <code>JTable</code>.
         *  @param  table the table to provide support for
         public static void install(JTable table)
              table.getTableHeader().addMouseListener( getInstance() );
         *  Remove support for the management of visible <code>TableColumns</code>
         *  for a given <code>JTable</code>.
         *  @param  table the table to remove support from
         public static void uninstall(JTable table)
              table.getTableHeader().removeMouseListener( getInstance() );
         *  Hide a column from view in the table.
         *  @param  table        the table from which the column is removed
         *  @param  modelColumn  the column index from the TableModel
         *                       of the column to be removed
         public static void hideColumn(JTable table, int modelColumn)
              int viewColumn = table.convertColumnIndexToView( modelColumn );
              if (viewColumn != -1)
                   TableColumn column = table.getColumnModel().getColumn(viewColumn);
                   hideColumn(table, column);
         *  Hide a column from view in the table.
         *  @param  table        the table from which the column is removed
         *  @param  columnName   the column name of the column to be removed
         public static void hideColumn(JTable table, String columnName)
              try
                   TableColumnModel tcm = table.getColumnModel();
                   int index = tcm.getColumnIndex( columnName );
                   TableColumn column = tcm.getColumn( index );
                   hideColumn(table, column);
              catch(IllegalArgumentException e) {}
         *  Hide a column from view in the table.
         *  @param  table   the table from which the column is removed
         *  @param  column  the TableColumn to be removed from the
         *                  TableColumnModel of the specified table
         public static void hideColumn(JTable table, TableColumn column)
              table.getColumnModel().removeColumn( column );
              //  Save the column so it can be redisplayed
              ArrayList list = (ArrayList)table.getClientProperty(HIDDEN_COLUMN);
              if (list == null)
                   list = new ArrayList();
                   table.putClientProperty(HIDDEN_COLUMN, list);
              list.add(column);
         *  Show a hidden column in the table.
         *  @param  table        the table to which the column is added
         *  @param  modelColumn  the column index from the <code>TableModel</code>
         *                       of the column to be added
         public static void showColumn(JTable table, int modelColumn)
              ArrayList list = (ArrayList)table.getClientProperty(HIDDEN_COLUMN);
              if (list == null) return;
              ListIterator it = list.listIterator();
              while (it.hasNext())
                   TableColumn column = (TableColumn)it.next();
                   if (column.getModelIndex() == modelColumn)
                        table.getColumnModel().addColumn( column );
                        it.remove();
                        break;
         *  Show a hidden column in the table.
         *  @param  table        the table to which the column is added
         *  @param  columnName   the column name from the <code>TableModel</code>
         *                       of the column to be added
         public static void showColumn(JTable table, String columnName)
              ArrayList list = (ArrayList)table.getClientProperty(HIDDEN_COLUMN);
              if (list == null) return;
              ListIterator it = list.listIterator();
              while (it.hasNext())
                   TableColumn column = (TableColumn)it.next();
                   if (column.getHeaderValue().equals(columnName))
                        table.getColumnModel().addColumn( column );
                        it.remove();
                        break;
         //  Implement the MouseListener
         public void mousePressed(MouseEvent e)
              checkForPopup( e );
         public void mouseReleased(MouseEvent e)
              checkForPopup( e );
         public void mouseClicked(MouseEvent e) {}
         public void mouseEntered(MouseEvent e) {}
         public void mouseExited(MouseEvent e) {}
         private void checkForPopup(MouseEvent e)
              if (e.isPopupTrigger())
                   JTableHeader header = (JTableHeader)e.getComponent();
                   int column = header.columnAtPoint( e.getPoint() );
                   showPopup(header.getTable(), column);
         *  Show a hidden column in the table.
         *  @param  table        the table to which the column is added
         *  @param  columnName   the column name from the <code>TableModel</code>
         *                       of the column to be added
         public static void showPopup(JTable table, int tableColumn)
              int columns = table.getModel().getColumnCount();
              JCheckBoxMenuItem[] items = new JCheckBoxMenuItem[columns];
              //  Create menu items for hidden columns
                 ArrayList list = (ArrayList)table.getClientProperty(HIDDEN_COLUMN);
                 if (list != null)
                   ListIterator it = list.listIterator();
                   while (it.hasNext())
                        TableColumn column = (TableColumn)it.next();
                        String columnName = column.getHeaderValue().toString();
                        JCheckBoxMenuItem item = new JCheckBoxMenuItem( columnName );
                        item.setSelected( false );
                        item.addActionListener(getInstance());
                        items[column.getModelIndex()] = item;
              //  Create menu items for visible columns
              TableColumnModel columnModel = table.getColumnModel();
              int columnCount = columnModel.getColumnCount();
              for (int i = 0; i < columnCount; i++)
                   TableColumn column = columnModel.getColumn(i);
                   String columnName = column.getHeaderValue().toString();
                   JCheckBoxMenuItem item = new JCheckBoxMenuItem( columnName );
                   item.setSelected( true );
                   item.addActionListener(getInstance());
                   items[column.getModelIndex()] = item;
              //  Create popup menu from array of menu items.
              //  Override the setSelected method to select the
              //  specified menu item. (ie. this is a bug fix)
              JPopupMenu popup = new JPopupMenu()
                   public void setSelected(Component sel)
                        int index = getComponentIndex( sel );
                        getSelectionModel().setSelectedIndex(index);
                        final MenuElement me[] = new MenuElement[2];
                        me[0]=(MenuElement)this;
                        me[1]=getSubElements()[index];
                        SwingUtilities.invokeLater(new Runnable()
                             public void run()
                                  MenuSelectionManager.defaultManager()
                                       .setSelectedPath(me);
              for (int i = 0; i < items.length; i++)
                   if (items[i] != null)
                        popup.add( items[i] );
              //  Display the popup below the TableHeader
              JTableHeader header = table.getTableHeader();
              Rectangle r = header.getHeaderRect( tableColumn );
              popup.show(header, r.x, r.height);
              int modelColumn = table.convertColumnIndexToModel( tableColumn );
              popup.setSelected( items[modelColumn] );
         *  Responsible for processing the ActionEvent. A column will either be
         *  added to the table or removed from the table depending on the state
         *  of the menu item that was clicked.
         * @param event the ActionEvent.
         public void actionPerformed(ActionEvent event)
              JMenuItem item = (JMenuItem)event.getSource();
              JPopupMenu popup = (JPopupMenu)item.getParent();
              JTableHeader header = (JTableHeader)popup.getInvoker();
              JTable table = header.getTable();
              if (item.isSelected())
                   showColumn(table, item.getText());
              else
                   hideColumn(table, item.getText());
         public static void main(String[] args)
              JTable table = new JTable( new DefaultTableModel(5, 10) );
              TableColumnManager.install(table);
              TableColumnManager.hideColumn(table, 2);
              TableColumnManager.hideColumn(table, "E");
              JFrame frame = new JFrame();
              frame.setDefaultCloseOperation( JFrame.EXIT_ON_CLOSE );
              frame.getContentPane().add( new JScrollPane(table) );
              frame.pack();
              frame.setVisible( true );
    }Hopefully I've made some sense.

  • To add column in an alv of FITV_POWL_TRIPS component

    Hi all
    I have a requirement to add column to an alv which is in FITV_POWL_TRIPS.Now the prob is that in that component we r using another  compent SALV_WD_TABLE from which alv is taken.This what I understood
    fitv_powl_trip
    powl_ui_comp- <-getting tabstrips
    powl_table_comp-<-getting refresh link
    salv_wd_table- <- getting table
    As far as I understood I think I have to find the comtext binded to DATA of SALV_WD_TABLE .Im not able to get it.If anyone has previous experience with this pls share
    Edited by: m.reeha verma on Apr 30, 2009 6:15 AM

    Hello Reeha,
    Could you please share the solution for this ?
    Thanks in Advance.
    Thanks,
    Prakhar

  • How to add column dynamically based on user input in oracle?

    **how to add column dynamically based on user input in oracle?**
    I am generating monthly report based on from_date to to_date below is my requirement sample table
    EMPLOYEE_CODE| Name | CL_TAKEN_DATE | CL_BALANCE | 01-OCT-12 | 02-OCT-12 | 03-OCT-12
    100001.............John...........02-OCT-12...............6
    100002.............chris...........01-OCT-12...............4
    Based on user input, that is, if user need the report from 01-OCT-12 TO 03-OCT-12, i need to add that dates as column in my table, like 01-OCT-12 | 02-OCT-12 | 03-OCT-12....
    below is my code
    create or replace
    procedure MONTHLY_LVE_NEW_REPORT_demo
    L_BUSINESS_UNIT IN SSHRMS_LEAVE_REQUEST_TRN.BUSINESS_UNIT%TYPE,
    --L_LEAVE_TYPE_CODE           IN SSHRMS_LEAVE_REQUEST_TRN.LEAVE_TYPE_CODE%TYPE,
    L_DEPARTMENT_CODE IN VARCHAR2,
    --L_MONTH                    IN SSHRMS_LEAVE_REQUEST_TRN.LVE_FROM_DATE%TYPE,
    L_FROM_DATE IN SSHRMS_LEAVE_REQUEST_TRN.LVE_FROM_DATE%TYPE,
    L_TO_DATE in SSHRMS_LEAVE_REQUEST_TRN.LVE_TO_DATE%type,
    MONTHRPT_CURSOR OUT SYS_REFCURSOR
    AS
    O_MONTHRPT_CURSOR_RPT clob;
    v_return_msg clob;
    BEGIN
    IF (L_BUSINESS_UNIT IS NOT NULL
    AND L_FROM_DATE IS NOT NULL
    and L_TO_DATE is not null
    -- AND L_DEPARTMENT_CODE IS NOT NULL
    THEN
    OPEN MONTHRPT_CURSOR FOR
    select EMPLOYEE_CODE, EMPLOYEE_NAME AS NAME, DEPARTMENT_CODE AS DEPARTMENT,DEPARTMENT_DESC, CREATED_DATE,
    NVL(WM_CONCAT(CL_RANGE),'') as CL_TAKEN_DATE,
    case when NVL(SUM(CL2),0)<0 then 0 else (NVL(SUM(CL2),0)) end as CL_BALANCE,
    from
    SELECT DISTINCT a.employee_code,
    a.EMPLOYEE_FIRST_NAME || ' ' || a.EMPLOYEE_LAST_NAME as EMPLOYEE_NAME,
    a.DEPARTMENT_CODE,
    a.DEPARTMENT_DESC,
    B.LEAVE_TYPE_CODE,
    B.LVE_UNITS_APPLIED,
    B.CREATED_DATE as CREATED_DATE,
    DECODE(b.leave_type_code,'CL',SSHRMS_LVE_BUSINESSDAY(L_BUSINESS_UNIT,to_char(b.lve_from_date,'mm/dd/yyyy'), to_char(b.lve_to_date,'mm/dd/yyyy'))) CL_RANGE,
    DECODE(B.LEAVE_TYPE_CODE,'CL',B.LVE_UNITS_APPLIED)CL1,
    b.status
    from SSHRMS_EMPLOYEE_DATA a
    join
    SSHRMS_LEAVE_BALANCE C
    on a.EMPLOYEE_CODE = C.EMPLOYEE_CODE
    and C.STATUS = 'Y'
    left join
    SSHRMS_LEAVE_REQUEST_TRN B
    on
    B.EMPLOYEE_CODE=C.EMPLOYEE_CODE
    and c.EMPLOYEE_CODE = b.EMPLOYEE_CODE
    and B.LEAVE_TYPE_CODE = C.LEAVE_TYPE_CODE
    and B.STATUS in ('A','P','C')
    and (B.LVE_FROM_DATE >= TO_DATE(L_FROM_DATE, 'DD/MON/RRRR')
    and B.LVE_TO_DATE <= TO_DATE(L_TO_DATE, 'DD/MON/RRRR'))
    join
    SSHRMS_LEAVE_REQUEST_TRN D
    on a.EMPLOYEE_CODE = D.EMPLOYEE_CODE
    and D.LEAVE_TYPE_CODE in ('CL')
    AND D.LEAVE_TYPE_CODE IS NOT NULL
    group by EMPLOYEE_CODE, EMPLOYEE_NAME, DEPARTMENT_CODE, DEPARTMENT_DESC, CREATED_DATE
    else
    v_return_msg:='Field should not be empty';
    end if;
    END;
    my code actual output
    EMPLOYEE_CODE| Name | CL_TAKEN_DATE | CL_BALANCE
    100001....................John............02-OCT-12.................6
    100001....................chris...........01-OCT-12.................4
    how to add column dynamically based on from_date to to_date?
    Thanks and Regards,
    Chris Jerome.

    You cannot add columns dynamically. But you can define a maximum number of numbers and then hide unused columns in your form useing SET_ITEM_PROPERTY(..,VISIBLE, PROPERTY_FALSE);

  • How to add columns in field-symbol

    Dear All,
                  Have made a report for HR - ZHR_CTC by using logical database and field-symbol. Report is working fine, but now have to add columns e.g business area text, positions text etc.
    Have added columns in field-symbol.But not able to fetch data into that.
    Data has to be fetched from different trasparent table comparing <field-symbol>-field.
    Plz suggest the proper way to do it.
    <<text removed>>
    Regards,
    Gulrez Alam
    Edited by: Gulrez Alam on Dec 16, 2008 11:02 AM
    Edited by: Matt on Dec 16, 2008 11:36 AM

    Hi Rimpa,
                   Thanks a lot for you reply, have tried ur suggestion but it's not working. I am not able to understand how to insert data into field-symbol. Plz give some more clarifications about the same.
    Regards,
    Gulrez Alam

  • How do i change the color of a JTable's column names

    hai,
    i'm very new to java and trying to customize the look of a JTable.
    how do i change the color of a JTable's Column names. i know its very simple, i just couldn't figure out how to do it!!
    thanx in advance

    table.getTableHeader().setForeground(Color.RED);

  • How to add column access BADI to appraisal template.

    I am not able to see option to add column access BADI in template at Processing  tab--> Further template behaviour.
    Kinldy let me know how to add it.
    I am able to see only following options
    BC         Business Check
    D1         Default Appraiser
    D2         Default Appraisee
    DE         Default Execution Period
    DN         Default Appraisal Document Name
    DP         Default Part Appraiser
    DR         Default Review Date
    DV         Default Validity Period
    HA         Header Data Change
    PM         Maximum Number of Part Appraisers
    Thanks in advance.
    Dhananjy

    Hello Ravikiran,
    Based on the Role and Status of the appraisal form, turn the Column On/Off/Hide..
    sample code...
    case s_header_status-ap_status.
              when c_status_in_preparation.
                availability = 'H'.
                column_owner   = space.
              when  c_status_in_planning.
                case s_body_columns-column_id.
                  when 'OBJ0'.
                    availability   = 'X'.
                    column_owner   = 'X'.
                    exit.
                  when 'Z003'.
                    availability   = 'X'.
                    column_owner   = 'X'.
    Hope it helps...
    Regards,
    Jothi.P

  • Add columns in system matrix

    Hi experts,
    I need help urgently. I want to add columns in the matrix of A/R invoice system form.
    Can someone give me a solution?
    Regards.
    Olivier

    Olivier
    You can add user defined fields into Marketing document rows, these will be new  columns and will appear U_[COLUMNAME]
    Regards
    J
    Edited by: János Nagy on May 18, 2010 2:01 PM

  • Add Column name conditionally in a query

    Hi i have an stored procedure where one parameter is passing
    @Type
    UserTable (columns) => username, canAdminDelete,canCustomerDelete,CanMerchantDelete
    i wants to add column conditionally like when usertype =1 then query should be like
    Select * from userTable where canAdminDelete=0
    when userType=2
    Select * from userTable where canCustomerDelete=0
    Like in this way. I know i can write three if statments and write specific query.
    But this is just an example i have very big query actually.
    Please give some idea.
    Thanks
    Niki

    Hi Niki,
    As per my understanding, I think the query post by Olaf is correct. It only return the results when column canAdminDelete = 0 and userTpe = 1 or column canCustomerDelete = 0 and userType = 2.
    So when userType=1 and column canAdminDelete=1, how could you get the results? Could you please test the issue again based on the query post by Olaf.
    If there are any misunderstanding, please elaborate the issue for further investigation.
    Thanks,
    Katherine Xiong
    Katherine Xiong
    TechNet Community Support

  • How to Add column with default value in compress table.

    Hi ,
    while trying to add column to compressed table with default value i am getting error.
    Even i tried no compress command on table still its giivg error that add/drop not allowed on compressed table.
    Can anyone help me in this .
    Thanks.

    Aman wrote:
    while trying to add column to compressed table with default value i am getting error.This is clearly explain in the Oracle doc :
    "+You cannot add a column with a default value to a compressed table or to a partitioned table containing any compressed partition, unless you first disable compression for the table or partition+"
    http://download.oracle.com/docs/cd/B19306_01/server.102/b14200/statements_3001.htm#sthref5163
    Nicolas.

  • AdvancedDataGrid - Add columns with ActionScript

    I'm trying to add columns to an AdvancedDataGrid via ActionScript.
    I can't get it to work.
    I've tried two approaches -- One with an intermediary array to store the columns then set the adg's columns to the array; One where I assign the columns directly to the adg's columns array.
    They both fail in their own way.  The columns don't "take" and the adg uses the dataProviders defaults, or there are no columns at all.
    "adg_test.mxml" has the AdvancedDataGrids/code. 
    "adg_test_renderer.mxml" is a renderer for one of the columns.
    Would appreciate learning what I'm doing wrong.
    Thanks for any help.
    === START adg_test_renderer.mxml  ===
    <?xml version="1.0" encoding="utf-8"?>
    <mx:VBox xmlns:mx="http://www.adobe.com/2006/mxml">
         <mx:Button id="btnTest" label="Renderer Working"/>
    </mx:VBox>
    === END adg_test_renderer.mxml  ===
    == START adg_test.mxml ====
    <?xml version="1.0"?>
    <mx:Application
        xmlns:mx="http://www.adobe.com/2006/mxml"
        initialize="init()">
        <mx:Script>
          <![CDATA[
             import mx.collections.ArrayCollection;
             [Bindable]
             private var dpADGExplicit:ArrayCollection = new ArrayCollection([
               {Artist:'Pavement', Album:'Slanted and Enchanted', Price:11.99},
               {Artist:'Pavement', Album:'Brighten the Corners', Price:11.99},
               {Artist:'Saner', Album:'A Child Once', Price:11.99},
               {Artist:'Saner', Album:'Helium Wings', Price:12.99},
               {Artist:'The Doors', Album:'The Doors', Price:10.99},
               {Artist:'The Doors', Album:'Morrison Hotel', Price:12.99},
               {Artist:'Grateful Dead', Album:'American Beauty', Price:11.99},
               {Artist:'Grateful Dead', Album:'In the Dark', Price:11.99},
               {Artist:'Grateful Dead', Album:'Shakedown Street', Price:11.99},
               {Artist:'The Doors', Album:'Strange Days', Price:12.99},
               {Artist:'The Doors', Album:'The Best of the Doors', Price:10.99}
             [Bindable]
             private var dpADGActionScript:ArrayCollection = new ArrayCollection([
               {Artist:'Pavement', Album:'Slanted and Enchanted', Price:11.99},
               {Artist:'Pavement', Album:'Brighten the Corners', Price:11.99},
               {Artist:'Saner', Album:'A Child Once', Price:11.99},
               {Artist:'Saner', Album:'Helium Wings', Price:12.99},
               {Artist:'The Doors', Album:'The Doors', Price:10.99},
               {Artist:'The Doors', Album:'Morrison Hotel', Price:12.99},
               {Artist:'Grateful Dead', Album:'American Beauty', Price:11.99},
               {Artist:'Grateful Dead', Album:'In the Dark', Price:11.99},
               {Artist:'Grateful Dead', Album:'Shakedown Street', Price:11.99},
               {Artist:'The Doors', Album:'Strange Days', Price:12.99},
               {Artist:'The Doors', Album:'The Best of the Doors', Price:10.99}
            private function init():void
                var arr:Array=[];//Intermediary array that will become the AdvancedDataGridColumn array
                var col:AdvancedDataGridColumn = new AdvancedDataGridColumn();
                col.dataField = "Artist";
                arr.push(col);
                col.dataField = "Album";
                col.visible = false;
                arr.push(col);
                col.dataField = "Price";
                col.itemRenderer = new ClassFactory(adg_test_renderer);
                arr.push(col);
                adgActionScript.columns = arr;
                //ALTERNATE UNSUCCESFUL APPROACH
                col.dataField = "Artist";
                adgActionScript.columns.push(col);
                col.dataField = "Album";
                col.visible = false;
                adgActionScript.columns.push(col);
                col.dataField = "Price";
                col.itemRenderer = new ClassFactory(adg_test_renderer);
                adgActionScript.columns.push(col);
          ]]>
        </mx:Script>
        <mx:Label text="Explicit Columns"/>
        <mx:AdvancedDataGrid
            id="adgExplicit"
            width="100%" height="100%"
            sortExpertMode="true"
            dataProvider="{dpADGExplicit}">
            <mx:columns>
                <mx:AdvancedDataGridColumn dataField="Artist" />
                <mx:AdvancedDataGridColumn dataField="Album" visible="false"/>
                <mx:AdvancedDataGridColumn dataField="Price" itemRenderer="adg_test_renderer"/>
            </mx:columns>
       </mx:AdvancedDataGrid>
       <mx:Label text="ActionScript Columns (If ActionScript works: Arist column should be hidden. Should see Album column with data and Price column with buttons."/>
        <mx:AdvancedDataGrid
            id="adgActionScript"
            width="100%" height="100%"
            sortExpertMode="true"
            dataProvider="{dpADGActionScript}">
       </mx:AdvancedDataGrid>
    </mx:Application>
    == END adg_test.mxml ====

    Thanks so much for your help.
    Here's how I altered your code for my example.  This logic allows easier assignment of additional column parameters.
    === START adg_test_renderer.mxml  ===
    <?xml version="1.0" encoding="utf-8"?>
    <mx:VBox xmlns:mx="http://www.adobe.com/2006/mxml">
        <mx:Button id="btnTest" label="Renderer Working"/>
    </mx:VBox>
    === END adg_test_renderer.mxml  ===
    == START adg_test.mxml ====
    <?xml version="1.0"?>
    <mx:Application
        xmlns:mx="http://www.adobe.com/2006/mxml"
        initialize="init()">
        <mx:Script>
          <![CDATA[
             import mx.collections.ArrayCollection;
             [Bindable]
             private var dpADGExplicit:ArrayCollection = new ArrayCollection([
               {Artist:'Pavement', Album:'Slanted and Enchanted', Price:11.99},
               {Artist:'Pavement', Album:'Brighten the Corners', Price:11.99},
               {Artist:'Saner', Album:'A Child Once', Price:11.99},
               {Artist:'Saner', Album:'Helium Wings', Price:12.99},
               {Artist:'The Doors', Album:'The Doors', Price:10.99},
               {Artist:'The Doors', Album:'Morrison Hotel', Price:12.99},
               {Artist:'Grateful Dead', Album:'American Beauty', Price:11.99},
               {Artist:'Grateful Dead', Album:'In the Dark', Price:11.99},
               {Artist:'Grateful Dead', Album:'Shakedown Street', Price:11.99},
               {Artist:'The Doors', Album:'Strange Days', Price:12.99},
               {Artist:'The Doors', Album:'The Best of the Doors', Price:10.99}
             [Bindable]
             private var dpADGActionScript:ArrayCollection = new ArrayCollection([
               {Artist:'Pavement', Album:'Slanted and Enchanted', Price:11.99},
               {Artist:'Pavement', Album:'Brighten the Corners', Price:11.99},
               {Artist:'Saner', Album:'A Child Once', Price:11.99},
               {Artist:'Saner', Album:'Helium Wings', Price:12.99},
               {Artist:'The Doors', Album:'The Doors', Price:10.99},
               {Artist:'The Doors', Album:'Morrison Hotel', Price:12.99},
               {Artist:'Grateful Dead', Album:'American Beauty', Price:11.99},
               {Artist:'Grateful Dead', Album:'In the Dark', Price:11.99},
               {Artist:'Grateful Dead', Album:'Shakedown Street', Price:11.99},
               {Artist:'The Doors', Album:'Strange Days', Price:12.99},
               {Artist:'The Doors', Album:'The Best of the Doors', Price:10.99}
            private function init():void
                var arrCols:Array = adgActionScript.columns;
                var col:AdvancedDataGridColumn;
                col = new AdvancedDataGridColumn;
                col.dataField = "Artist";
                arrCols.push(col);
                col = new AdvancedDataGridColumn;
                col.dataField = "Album";
                col.visible = false;
                arrCols.push(col);
                col = new AdvancedDataGridColumn;
                col.dataField = "Price";
                col.itemRenderer = new ClassFactory(adg_test_renderer);
                arrCols.push(col);   
                adgActionScript.columns = arrCols;
                adgActionScript.validateNow();
          ]]>
        </mx:Script>
        <mx:Label text="Explicit Columns"/>
        <mx:AdvancedDataGrid
            id="adgExplicit"
            width="100%"
            height="100%"
            dataProvider="{dpADGExplicit}">
            <mx:columns>
                <mx:AdvancedDataGridColumn dataField="Artist" />
                <mx:AdvancedDataGridColumn dataField="Album" visible="false"/>
                <mx:AdvancedDataGridColumn dataField="Price" itemRenderer="adg_test_renderer"/>
            </mx:columns>
       </mx:AdvancedDataGrid>
       <mx:Label text="ActionScript Columns"/>
        <mx:AdvancedDataGrid
            id="adgActionScript"
            width="100%"
            height="100%"
            dataProvider="{dpADGActionScript}">
       </mx:AdvancedDataGrid>
    </mx:Application>
    == END adg_test.mxml ====

  • Add columns to RCOPOC_WKLT

    Hi.
    Does anyone know how can I add columns (from my structure) at the above report?
    It's the CO60 transaction (Worklist for PI Sheets).
    I think it's somthing about an enhancement for this report but how can I do it??
    Thanks,
    Rebeka

    Robeka
    There is no way you can do enhancement to add new column to the ALV.... See report RCOPOC_WKLT, subroutine "build_fieldcat"....
    Though, you can modify this report by using access key or create Z-Copy of this report and modify it....
    Thanks
    Amol Lohade

  • Operations in querie or add columns

    hi!.
    How can do operations in querie or add columns with operations.
    greetings.

    hi
    good
    go through this link hope this will give you idea of the query operation.
    http://help.sap.com/saphelp_nw70/helpdata/en/16/a6fe41b227096fe10000000a155106/content.htm
    thanks
    mrutyun^

  • Add Columns to Updatable Report

    Hello,
    i need some help regarding an "Updatable Report".
    My goal is to have some SelectLists in comluns named "2008_05", "2008_08", ....."2010_01", "2010_04".
    The user must have the option to add more cloumns.
    My process on submit is:
    declare
      SQL_STRING varchar2(4000);
    begin
      SQL_STRING :=  'ALTER TABLE TAB_REPORTS ADD "' || :P3700_COLUMN_NAME ||  '" varchar2(100)';
      EXECUTE IMMEDIATE(SQL_STRING);  
      return;
    end;At the moment I have this code for a standard report returning a SQL query:
    declare
      q varchar2(4000);
    begin
      q := 'SELECT R_ID, PLANT_NAME, UNIT_NO, R_TSO_NO TSO_NO';
      For i in (SELECT * FROM USER_TAB_COLUMNS
      WHERE table_name = 'TAB_REPORTS'
      AND column_name like '2%')
      loop
        q := q || ', ';
        q := q || 'APEX_ITEM.SELECT_LIST_FROM_LOV (1, ';
        q := q || chr(34);
        q := q || i.column_name;
        q := q || chr(34);
        q := q || ', ';
        q := q || chr(39);
        q := q || 'LOV_QER';
        q := q || chr(39);
        q := q || ', ';
        q := q || 'null';
        q := q || ', ';
        q := q || chr(39);
        q := q || 'Y';
        q := q || chr(39);
        q := q || ') as "';
        q := q || i.column_name;
        q := q || '"';
      end loop;
      q := q || ' FROM TAB_REPORTS ';
      q := q || ', TAB_SD';
      q := q || ', TAB_CONTACT';
      q := q || ' WHERE TSO_NO = R_TSO_NO';
      q := q || ' AND CON_PLANT_NAME = TAB_SD.PLANT_NAME';
      q := q || ' AND R_TSO_NO = decode(:P3700_FILTER_PLANT_NAME, ';
      q := q || chr(39);
      q := q || 'all';
      q := q || chr(39);
      q := q || ', R_TSO_NO, :P3700_FILTER_PLANT_NAME)';
      q := q || ' ORDER by PLANT_NAME, UNIT_NO';
      return q;
    END;The function returning a SQL is not working for an updatable report.
    It has to be static i think.
    Any solutions or ideas?
    Thx & greetings
    Chris

    Problem solved. See [this post|Add columns to CV04N report;
    Regards.
    Gregory.

Maybe you are looking for

  • Getting error while posting actual expense to f-02

    HI Every one Getting error while posting actual expense to f-02.Iam trying to post simple expense transation against a WBS element but iam getting the following error "FI: Postings" is not allowed for WBS element".Even i checked the status profile.In

  • How can I install CS5 on my new iMac.

    After replacing a crashed computer Irestored my information from time machine onto my new iMac.  CS5 apps will not launch.  An error message indicates a licensing problem.  I am unable to contact by phone anyone at adobe to help. 

  • Order of tracks in MuVo V100

    My MuVo V00 currently plays the tracks of an album in alphabetical order, not in the order of the album. How do I change this? The tracks have been ripped by using MuVos own program.

  • Find the Missing font text content in indesign document

    How to find and get the missing font content in the indesign documents by using the SDK. give a tips and techniques. Anybodys help me.

  • Crystal Reports 8.5 to XI

    Post Author: RobDog888 CA Forum: General Hello Members, I had written some reports in 8.5 a while back and work with them with VB 6. Now CR 8.5/9 dependnacy files are on the server but recently they bought/installed CR XI on it too now. I was wanting