Adding a Row to Table, ComboBox as a  TableCellRenderer Problem !!

Hell All:
I have a JTable with one of the Cell as ComboBox. Initially I draw the JTable with Three Rows and the
the ComboBox in the Second Column works fine. I see each comboBox has different Items. The ComboBox also has a Renderer (as I am customizing the Item's Text )
Here is the snippet from my Code.
==========================
// UIEditSubAllocation.ALT_ACCOUNT = 2;
// Get the Viewindex.... to get the correct column
int viewIndex = this.m_suballocTable.convertColumnIndexToView(UIEditSubAllocation.ALT_ACCOUNT);
// get the Table Column...
TableColumn altActColumn = this.m_suballocTable.getColumnModel().getColumn(UIEditSubAllocation.ALT_ACCOUNT);
// Create Three ComboBox..
JComboBox[] altActCell = new JComboBox[3];
for (int i =0;i< 3;++i) // adding Three Rows of Table Data...
String [] alternateAccounts = new String[4];
for(int j = 0; j < alternateAccounts.length; j++) // Each Alternate Accounts i.e combobox has 4 items..
alternateAccounts[0] = "Tom";
alternateAccounts[0] = "Vic";
alternateAccounts[0] = "Tracy";
alternateAccounts[0] = "Andy";
altActCell[i] = new AltAccountComboBox(alternateAccounts,this.m_suballocTable);
} // End of adding Three Rows
altActColumn.setCellRenderer(new AltAccountTableCellRenderer());
if (viewIndex >= 0)
ComboBoxEditor altActCellEditor = new ComboBoxEditor(altActCell);
altActColumn.setCellEditor(altActCellEditor);
The CombBoxEditor code is...
ublic class ComboBoxEditor extends DefaultCellEditor
* Constructs a ComboBoxEditor that uses an array of items of type object.
* @param items - an array of items of type object
public JComboBox[] m_comboBox;
public ComboBoxEditor(JComboBox[] box)
super(box[0]);
m_comboBox = box;
for(int i = 0; i < box.length; i++)
m_comboBox.setEditable(false);
public Component getTableCellEditorComponent(JTable table, Object value, boolean isSelected, int row, int column)
if(row >= this.m_comboBox.length)
return super.getTableCellEditorComponent(table, value, isSelected, row, column);
return m_comboBox[row];
But when I click a Button (in a Panel) which adds a Row (with No values for the ComboBox ).. to the Jtable .. The Row Gets added fine.. but the JComboBox comes with Values from the First Row's ComboBox. I Don't want any Values in the JComboBox for the new added Row. Can someone tell me
how do I remove the Items from the ComboBox.
I will really appreciate for any help...
Thanks
-Pankaj

Hi ,
as per my opinion one approach would be that ,
you create a custom table region same as standard one using Jdeveloper and create other required fields also using jeveloper ,and then put this region in extend property of existing standard table region .
thanks
Pratap

Similar Messages

  • Null Pointer Exception When Adding New Row on Table

    Hello JheadStart Team
    I have used detail group with table layout , when I am clicking on AddRow button on detail table , I encounter NulllPointer Exception . I have traced the code and fount that in JhsCollectionModel when adding new row following
    condition occurs :
    DCIteratorBinding ib = getRangeBinding().getIteratorBinding();
    int rangeSize = ib.getRangeSize();
    int rowsInRange = ib.getAllRowsInRange().length;
    because getAllRowsInRange is Null then the error raise.
    My JheadStart ver is 10.1.3.3.85 .
    Detail Group with table layout setting is :
    Use Table range=true
    Show New Row at top=true
    New Rows:empty
    Show Add New Row Button :true
    Regards

    Given the build you are using, I assume you are an Oracle employee.
    Is this correct? if so, please post your question to the [email protected] mailing list.
    Steven Davelaar,
    JHeadstart team.

  • Adding new rows to table - using TableRowSorter & RowFilter

    Hi all,
    I have a table where the user can add new rows by selecting a JButton. I have added a text box which allows the user to search for a String value and this filters the table contents and this is all working fine...But when I go to add a new row I get the following exception:
    java.lang.IndexOutOfBoundsException: Invalid range which seems to originate from DefaultRowSorter.rowsInsertedCould someone please give me any ideas to why this is happening, maybe the number of rows that are in the table orginally is set to x and when I add a new row the TableRowSorter is expecting that number not x + 1 which is added due to the button being pressed?
    Seems like I need to update the TableRowSorter to inform it that a new row has been added or something similar to that,
    Thanks,

    If you need further help then you need to create a [Short, Self Contained, Compilable and Executable, Example Program (SSCCE)|http://homepage1.nifty.com/algafield/sscce.html], that demonstrates the incorrect behaviour.
    Don't forget to use the Code Formatting Tags so the posted code retains its original formatting. That is done by selecting the code and then clicking on the "Code" button above the question input area.

  • Button inconsistently working when Adding dynamic rows in table

    I have a very weird situation at hand.
    I have several pages in my interactive form. 6 pages total.
    Pages 3-6 have dynamic tables wherein I used a button to add rows to my tables.
    Page 3: 2 tables working ok
    Page 4: 3 tables, 1st table working ok, the rest add button not responding
    Page 5-6: all add buttons are not responding
    I have this javascript that should run when the button is clicked.
    Table5.Data_Row5.instanceManager.addInstance(1);
    I have checked the table names and body rownames and all are correct.
    Would anyone point me what I did wrong? I tried deleting the buttons and recreating them and of course reentering the script again but still not working.

    I got it! I forgot to tick the Repeat Row for each data item on the body row for the succeeding tables.

  • Adding/delete/copy a row in table in web dynpro

    Hi Expers,
    We  have  arequirement where on screen of view there is a "ADD" button,"DELETE" button and a ":COPY" button. once the user click on "ADD" button , a new row must add in the existing table,once the user select a  row from table and click on "DELETE" button , that row must delete .once the user click "COPY" button a new row must added with the data of the selected row.
    Can you plz help me how to do this.
    Thanks
    Mahesh

    Hi Mahesh,
    -> To add a new row to the table, you need to create and bind  a new element to the node.
    DATA: lo_nd_test TYPE REF TO if_wd_context_node,
            lo_el_test TYPE REF TO if_wd_context_element,
    ls_test TYPE wd_this->element_test.
      lo_nd_test= wd_context->get_child_node( name = wd_this->wdctx_test ).
      lo_el_test= lo_nd_test->create_element( ).
      lo_nd_test->bind_element( new_item = lo_el_test set_initial_elements = abap_false ).
      lo_nd_test->set_lead_selection( lo_el_test ).   " to select the new row added
    -> To delete the exisiting row, get the selected row element and call remove_element method.
    lo_el_test= lo_nd_test->get_lead_selection( ).
    lo_nd_test->remove_element( lo_el_test ).
    -> To copy the existing row, get the values of the selected row using get_static_attributes( ) method and set the values to the new row added.
      lo_nd_test= wd_context->get_child_node( name = wd_this->wdctx_test ).
      lo_el_test= lo_nd_test->get_lead_selection( ).
      check lo_el_test is not initial.
      lo_el_test->get_Static_attributes( importing static_attributes = ls_test ).
      clear  lo_el_test.
      lo_el_test= lo_nd_test->create_element( ).
      lo_nd_test->bind_element( new_item = lo_el_test set_initial_elements = abap_false ).
      lo_el_test->set_Static_attributes(EXPORTING static_attributes = ls_test ).
    Regards,
    Manogna

  • Adding one additional row to table control of VA01

    HI all,
    I am working on free goods N:N senario which is not supported by sap standard.
    so we have decided to club all the material on the basis of material group and PSTYV = 'tann' in the table control of va01 and at the end of tann we have to display the free goods .The user exit is USEREXIT_MOVE_FIELD_TO_KOMP.
    Please help in in adding the additional row in table control of va01 (TCTRL_U_ERF_AUFTRAG).
    Even i have gone through all the thread in sdn and tried all the solution but none of the solution is working .
    plz quote solutions....
    thanks..
    Kundal.

    The user exit is USEREXIT_MOVE_FIELD_TO_KOMP
    Are you adding condition records, or adding free materials to VBAP?  If free materials to VBAP, you're in the wrong exit, I think....look for routines that allow you to add to internal table XVBAP in includes named like MV45AFZ*, and remember to set you UPDKZ to 'I'-insert if you're adding new rows.
    Not sure what you mean by not supported by SAP standard;  SAP does support free goods, via config!
    Edited by: BreakPoint on Mar 14, 2011 4:11 PM

  • Adding/Deleting rows in a Table

    I am trying to get a couple of buttons to work in a table to add/delete rows. I have followed the directions in the LiveCycle designer help and it isn't working.
    In a test setup the only difference I can see from the help file is my Table is called Table1 and the subform containing the 2 buttons is called Subform1
    I have therefore amended the script for the click event for the AddRow to
    "Table1.Row1.instanceManager.addInstance(1);"
    Any ideas where I am going wrong?
    TIA
    Antony

    Hi,
    My usecase is that user enters a url with parameters for example in the text box--> http://host:port/employee/all?department=abc&location=india. Now i want to parse this url , get the parameters out and put it in the table so that it is convenient for users to modify these parameters. User has a option to add and delete the parameter in the table. So once all this is done and user clicks on say save i don't need to send this table to server. i just have to make sure that the values added/deleted from the table are in sync with the url. So in the server i get all the parameters from the url and continue.
    Since this is only needed on the client side i wanted to know if we can create a table with no values and then say on tabbing out of the url text box call a javascript that takes value from it and adds new rows to the table.
    I am using JDEVADF_MAIN_GENERIC_140109.0434.S

  • How to default the value of a selectOneChoice when adding a row to a table

    I have a table where one of the fields is a selectOneChoice. When adding a row to the table, the new row to be added displays the selectoneChoice field blank. I would like to have this field default to a specific value within the selectoneChoice when clicking the add button. Any suggestion on the code I need to add in the backing bean? Thanks in advance.

    After some studying I figured out how to do this... code below for anyone interested:
    DCIteratorBinding dcib = (DCIteratorBinding) bindings.get("someIterator");
    RowSetIterator iter = dcib.getRowSetIterator();
    Row newRow = iter.createRow();
    newRow.setAttribute("yourFieldName",fieldDefaultValue);
    iter.insertRowAtRangeIndex(0, newRow);
    iter.closeRowSetIterator();

  • Adding a button in each row of table view

    Hi.
    In my application i have to add a button in each row of table view. i have done this by using UICatalog example. now problem is how I can handle the click events of these buttons.
    suppose i have 5 buttons in 5 rows ... now one of them is clicked(suppose button in 3rd row). how would i know that button in 3rd row is clicked.
    Muhammad Usman Aleem

    - (UITableViewCell)tableView:(UITableView)tableView
    cellForRowAtIndexPath:(NSIndexPath*)indexPath {
    static NSString *CellTableIdentifier = @"CellTableIdentifier ";
    static NSUInteger nTag = 100;
    UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:
    CellTableIdentifier];
    if (cell == nil) {
    CGRect cellFrame = CGRectMake(0, 0, 300, 65);
    cell = [[[UITableViewCell alloc] initWithFrame:cellFrame
    reuseIdentifier:CellTableIdentifier] autorelease];
    CGRect labelRect = CGRectMake(10, 26, 190, 15);
    UILabel *label = [[UILabel alloc] initWithFrame:labelRect];
    label.textAlignment = UITextAlignmentLeft;
    label.font = [UIFont boldSystemFontOfSize:12];
    // set all label tags to 10 so the label can be found in the subviews
    label.tag = 10;
    [cell.contentView addSubview:label];
    [label release];
    CGRect buttonRect = CGRectMake(210, 25, 65, 25);
    UIButton *button = [UIButton buttonWithType:UIButtonTypeRoundedRect];
    button.frame = buttonRect;
    // set the button title here if it will always be the same
    [button setTitle:@"Action" forState:UIControlStateNormal];
    button.tag = nTag++;
    [button addTarget:self action:@selector(myAction:) forControlEvents:UIControlEventTouchUpInside];
    // make sure the button is the lowest subview so it's easy to find
    [cell.contentView insertSubview:button atIndex:0];
    // button will be autoreleased so don't release it here
    // the label text and button title come from an array of NSDictionary in this example
    NSUInteger row = [indexPath row];
    NSDictionary *rowData = [self.data objectAtIndex:row];
    UILabel *thisLabel = (UILabel*)[cell.contentView viewWithTag:10];
    thisLabel.text = [rowData objectForKey:@"Text"];
    // set the button title here if it depends on the row
    UIButton *thisButton = [[cell.contentView subviews] objectAtIndex:0];
    [thisButton setTitle:[rowData objectForKey:@"Button"] forState:UIControlStateNormal];
    return cell;
    - (IBAction)myAction:(id)sender {
    UIButton *theSender = sender;
    UITableViewCell *cell;
    NSUInteger row = 0;
    for (cell in [theTableView visibleCells]) {
    UIButton *thisButton = [[cell.contentView subviews] objectAtIndex:0];
    if (thisButton.tag == theSender.tag) {
    row = [[theTableView indexPathForCell:cell] row];
    break;
    NSLog(@"myAction: row=%d", row);

  • Problem in adding/deleting rows in JTable

    I am trying to add /remove rows from JTable whose first column is JButton and others are JComboBox's.If no rows are selected,new row is added at the end.If user selects some row & then presses insert button,new row is added below it.Rows can only be deleted if user has made some selection.Kindly help me,where i am making mistake.If any function is to be used.My code is as follows....
    import java.awt.*;
    import java.awt.event.*;
    import javax.swing.*;
    import javax.swing.table.*;
    import javax.swing.border.*;
    public class JButtonTableExample extends JFrame implements ActionListener{
    JComboBox mComboLHSType = new JComboBox();
    JComboBox mComboRHSType = new JComboBox();
    JLabel mLabelLHSType = new JLabel("LHS Type");
    JLabel mLabelRHSType = new JLabel("RHS Type");
    JButton mButtonDelete = new JButton("Delete");
    JButton mButtonInsert = new JButton("Insert");
    JPanel mPanelButton = new JPanel();
    JPanel mPanelScroll = new JPanel();
    JPanel mPanelCombo = new JPanel();
    DefaultTableModel dm ;
    JTable table;
    int currentRow = -1;
    static int mSelectedRow = -1;
    public JButtonTableExample()
    super( "JButtonTable Example" );
    makeForm();
    setSize( 410, 222 );
    setVisible(true);
    private void makeForm()
    this.getContentPane().setLayout(null);
    mPanelCombo.setLayout(null);
    mPanelCombo.setBorder(new LineBorder(Color.red));
    mPanelCombo.setBounds(new Rectangle(1,1,400,30));
    mLabelLHSType.setBounds(new Rectangle(26,5,71,22));
    mComboLHSType.setBounds(new Rectangle(83,5,100,22));
    mLabelRHSType.setBounds(new Rectangle(232,5,71,22));
    mComboRHSType.setBounds(new Rectangle(292,5,100,22));
    mPanelCombo.add(mLabelLHSType,null);
    mPanelCombo.add(mComboLHSType,null);
    mPanelCombo.add(mLabelRHSType,null);
    mPanelCombo.add(mComboRHSType,null);
    mPanelScroll.setLayout(null);
    mPanelScroll.setBorder(new LineBorder(Color.blue));
    mPanelScroll.setBounds(new Rectangle(1,28,400,135));
    mPanelButton.setLayout(null);
    mPanelButton.setBorder(new LineBorder(Color.green));
    mPanelButton.setBounds(new Rectangle(1,165,400,30));
    mButtonInsert.setBounds(new Rectangle(120,5,71,22));
    mButtonDelete.setBounds(new Rectangle(202,5,71,22));
    mButtonDelete.addActionListener(this);
    mButtonInsert.addActionListener(this);
    mPanelButton.add(mButtonDelete,null);
    mPanelButton.add(mButtonInsert,null);
    dm = new DefaultTableModel();
    //dm.setDataVector(null,
    //new Object[]{"Button","Join","LHS","Operator","RHS"});
    dm.setDataVector(new Object[][]{{"","","","",""}},
    new Object[]{"","Join","LHS","Operator","RHS"});
    table = new JTable(dm);
    table.getTableHeader().setReorderingAllowed(false);
    table.setRowHeight(25);
    int columnWidth[] = {20,45,95,95,95};
    TableColumnModel modelCol = table.getColumnModel();
    for (int i=0;i<5;i++)
    modelCol.getColumn(i).setPreferredWidth(columnWidth);
    //modelCol.getColumn(0).setCellRenderer(new ButtonRenderer());
    //modelCol.getColumn(0).setCellEditor(new ButtonEditor(new JCheckBox()));
    modelCol.getColumn(0).setCellRenderer(new ButtonCR());
    modelCol.getColumn(0).setCellEditor(new ButtonCE(new JCheckBox()));
    modelCol.getColumn(0).setResizable(false);
    setUpJoinColumn(modelCol.getColumn(1));
    setUpLHSColumn(modelCol.getColumn(2));
    setUpOperColumn(modelCol.getColumn(3));
    setUpRHSColumn(modelCol.getColumn(4));
    JScrollPane scroll = new JScrollPane(table);
    scroll.setBounds(new Rectangle(1,1,400,133));
    mPanelScroll.add(scroll,null);
    this.getContentPane().add(mPanelCombo,null);
    this.getContentPane().add(mPanelScroll,null);
    this.getContentPane().add(mPanelButton,null);
    }//end of makeForm()
    public void actionPerformed(ActionEvent ae)
    if (ae.getSource() == mButtonInsert)
    //int currentRow = table.getSelectedRow();
    currentRow = ButtonCE.selectedRow;
    System.out.println("Before Insert CURRENT ROW"+currentRow);
    if(currentRow == -1)
    int rowCount = dm.getRowCount();
    //mSelectedRow = rowCount-1;
    //table.clearSelection();
    dm.insertRow(rowCount,new Object[]{"","","","",""});
    currentRow = -1;
    ButtonCE.selectedRow = -1;
    else
    table.clearSelection();
    dm.insertRow(currentRow+1,new Object[]{"","","","",""});
    currentRow = -1;
    ButtonCE.selectedRow = -1;
    //System.out.println("After INSERT CURRENT ROW"+currentRow);
    if(ae.getSource() == mButtonDelete)
    //int currentRow = table.getSelectedRow();
    currentRow = ButtonCE.selectedRow;
    System.out.println("Before DELETE CURRENT ROW"+currentRow);
    if(currentRow != -1)
    dm.removeRow(currentRow);
    table.clearSelection();
    currentRow = -1;
    ButtonCE.selectedRow = -1;
    //System.out.println("Selected Row"+mSelectedRow);
    else
    JOptionPane.showMessageDialog(null, "Select row first", "alert", JOptionPane.ERROR_MESSAGE);
    //System.out.println("DELETE CURRENT ROW"+currentRow);
    public void setUpJoinColumn(TableColumn joinColumn)
    //Set up the editor for the sport cells.
    JComboBox comboBox = new JComboBox();
    comboBox.addItem("AND");
    comboBox.addItem("OR");
    comboBox.addItem("NOT");
    joinColumn.setCellEditor(new DefaultCellEditor(comboBox));
    //Set up tool tips for the sport cells.
    DefaultTableCellRenderer renderer =
    new DefaultTableCellRenderer();
    renderer.setToolTipText("Click for combo box");
    joinColumn.setCellRenderer(renderer);
    //Set up tool tip for the sport column header.
    TableCellRenderer headerRenderer = joinColumn.getHeaderRenderer();
    if (headerRenderer instanceof DefaultTableCellRenderer) {
    ((DefaultTableCellRenderer)headerRenderer).setToolTipText(
    "Click the sport to see a list of choices");
    public void setUpLHSColumn(TableColumn LHSColumn)
    //Set up the editor for the sport cells.
    JComboBox comboBox = new JComboBox();
    comboBox.addItem("Participant1");
    comboBox.addItem("Participant2");
    comboBox.addItem("Variable1");
    LHSColumn.setCellEditor(new DefaultCellEditor(comboBox));
    //Set up tool tips for the sport cells.
    DefaultTableCellRenderer renderer =
    new DefaultTableCellRenderer();
    renderer.setToolTipText("Click for combo box");
    LHSColumn.setCellRenderer(renderer);
    //Set up tool tip for the sport column header.
    TableCellRenderer headerRenderer = LHSColumn.getHeaderRenderer();
    if (headerRenderer instanceof DefaultTableCellRenderer) {
    ((DefaultTableCellRenderer)headerRenderer).setToolTipText(
    "Click the sport to see a list of choices");
    public void setUpOperColumn(TableColumn operColumn)
    //Set up the editor for the sport cells.
    JComboBox comboBox = new JComboBox();
    comboBox.addItem("=");
    comboBox.addItem("!=");
    comboBox.addItem("Contains");
    operColumn.setCellEditor(new DefaultCellEditor(comboBox));
    //Set up tool tips for the sport cells.
    DefaultTableCellRenderer renderer =
    new DefaultTableCellRenderer();
    renderer.setToolTipText("Click for combo box");
    operColumn.setCellRenderer(renderer);
    //Set up tool tip for the sport column header.
    TableCellRenderer headerRenderer = operColumn.getHeaderRenderer();
    if (headerRenderer instanceof DefaultTableCellRenderer) {
    ((DefaultTableCellRenderer)headerRenderer).setToolTipText(
    "Click the sport to see a list of choices");
    public void setUpRHSColumn(TableColumn rhsColumn)
    //Set up the editor for the sport cells.
    JComboBox comboBox = new JComboBox();
    comboBox.addItem("Variable1");
    comboBox.addItem("Constant1");
    comboBox.addItem("Constant2");
    rhsColumn.setCellEditor(new DefaultCellEditor(comboBox));
    //Set up tool tips for the sport cells.
    DefaultTableCellRenderer renderer =
    new DefaultTableCellRenderer();
    renderer.setToolTipText("Click for combo box");
    rhsColumn.setCellRenderer(renderer);
    //Set up tool tip for the sport column header.
    TableCellRenderer headerRenderer = rhsColumn.getHeaderRenderer();
    if (headerRenderer instanceof DefaultTableCellRenderer) {
    ((DefaultTableCellRenderer)headerRenderer).setToolTipText(
    "Click the sport to see a list of choices");
    public static void main(String[] args) {
    JButtonTableExample frame = new JButtonTableExample();
    frame.addWindowListener(new WindowAdapter() {
    public void windowClosing(WindowEvent e) {
    System.exit(0);
    //Button as a renderer for the table cells
    class ButtonCR implements TableCellRenderer
    JButton btnSelect;
    public ButtonCR()
    btnSelect = new JButton();
    btnSelect.setMargin(new Insets(0,0,0,0));
    public Component getTableCellRendererComponent(JTable table,Object value,boolean isSelected,boolean hasFocus,int row,int column)
    if (column != 0) return null; //meany !!!
    //System.out.println("Inside renderer########################Selected row");
    //btnSelect.setText(value.toString());
    //btnSelect.setIcon(new ImageIcon("capsigma.gif"));
    return btnSelect;
    }//end fo ButtonCR
    //Default Editor for table
    class ButtonCE extends DefaultCellEditor implements ActionListener
    JButton btnSelect;
    JTable table;
    //Object val;
    static int selectedRow = -1;
    public ButtonCE(JCheckBox whoCares)
    super(whoCares);
    //this.row = row;
    btnSelect = new JButton();
    btnSelect.setMargin(new Insets(0,0,0,0));
    btnSelect.addActionListener(this);
    setClickCountToStart(1);
    public Component getTableCellEditorComponent(JTable table,Object value,boolean isSelected,int row,int column)
    if (column != 0) return null; //meany !!!
    this.selectedRow = row;
    this.table = table;
    table.clearSelection();
    System.out.println("Inside getTableCellEditorComponent");
    return btnSelect;
    //public Object getCellEditorValue()
    //return val;
    public void actionPerformed(ActionEvent e)
    // Your Code Here...
    System.out.println("Inside actionPerformed");
    System.out.println("Action performed Row selected "+selectedRow);
    btnSelect.setIcon(new ImageIcon("capsigma.gif"));
    }//end of ButtonCE

    Hi,
    All the thing you have to do is to return a boolean for the column. JTable will use a checkbox (as default) to show boolean values.

  • Applescript on Numbers to copy rows between tables

    Hi,
    I am an applescript newbie, but am trying to make my book-keeping spreadsheet a bit more comfortable. And this is the problem:
    I have expenses that repeat every month and I would like to not have to rewrite them each time. So I thought I make a second table where I list all the repeating data and copy them into my main table. This works simply with selecting the row and then copy and paste in to the row of the main table.
    But I would like to make it nicer, and my concept is to make this copy process simpler, by memorizing the row number of the second table, (e.g. row 5 contains the rental costs for my studio ), so I would select the last row and then type the number of the expected row in table 2 and have the content be automatically copied into the selected row of table 1 (main table).
    I got the script to do so except the shortcuts for the keys. And I have no idea how to make the script understand that if I press the key for number "5" to start copying row 5 of table 2 into the last row of table 1. Here is my script as far as I got (it is far from finished I know, it is a test with 4 columns named "Art des Umsatzes", "Kategorie", "Projekt", "Betrag".
    If anyone could give me advice ho to define that the keystrokes become variable b and d, I think I would be able to manage the rest.
    Many thanks
    Hans Peter
                  tell application "Numbers"
                               tell table 2 of sheet 1 of document 1
                                         set a to b
                                         set tags to {"Art des Umsatzes", "Kategorie", "Projekt", "Betrag"}
                                         set tagValues to {}
                                         set theRange to "B" & a + 1 & ":" & "G" & a + 1
                                         set C to 1
                                         set setArt to value of cell C of range theRange
                                         set C to (C + 1)
                                         set setKat to value of cell C of range theRange
                                         set C to (C + 1)         
                                         set setProj to value of cell C of range theRange
                                         set C to (C + 1)
                                         set setBetr to value of cell C of range theRange   
                               end tell
                               tell table 1 of sheet 1 of document 1
                                         set a to d
                                         set tags to {"Art des Umsatzes", "Kategorie", "Projekt", "Betrag"}
                                         set tagValues to {}
                                         set theRange to "B" & a + 1 & ":" & "G" & a + 1
                                         set C to 1
                                         set value of cell C of range theRange to setArt
                                         set C to (C + 1)
                                         set value of cell C of range theRange to setKat
                                         set C to (C + 1)
                                         set value of cell C of range theRange to setProj
                                         set C to (C + 1)
                                         set value of cell C of range theRange to setBetr
                              end tell
                   end tell

    Hi HD
    thanks for your prompt and very helpful response. Although I had to add some more, your suggestion paved the way. Your simpler suggestion with the reference does not really work (sorry.)
    This is the solution. what you need to do is make 2 table. The first on has one row (title row) and 5 columns (first is title again). The second has 6 rows (one title) and 5 columns (first one title). then you fill in each of the cells a word or number.
    Run the script and choose one of the 5 numbers, one row will be added and filled. That's what I hoped to get, only I cannot type, I have to click the number. That is a bit a shame, do you think Automator could make a bridge to connect the script number to the keys?
    Well, anyhow. Thanks again for your great help.
    All the best, Hans Peter
               tell application "Numbers"
                               tell table 2 of sheet 1 of document 1
                                         set b to (choose from list {1, 2, 3, 4, 5} with prompt "Nummer des Schlüssel")
                                         if the result is false then return
                                         set a to b as integer
                                         set tags to {"Art des Umsatzes", "Kategorie", "Projekt", "Betrag"}
                                         set tagValues to {}
                                         set theRange to "B" & a + 1 & ":" & "G" & a + 1
                                         set C to 1
                                         set setArt to value of cell C of range theRange
                                         set C to (C + 1)
                                         set setKat to value of cell C of range theRange
                                         set C to (C + 1)
                                         set setProj to value of cell C of range theRange
                                         set C to (C + 1)
                                         set setBetr to value of cell C of range theRange
                               end tell
                               tell table 1 of sheet 1 of document 1
                                         set d to count row
                                         add row below last row
                                         set d to d + 1
                                         set tags to {"Art des Umsatzes", "Kategorie", "Projekt", "Betrag"}
                                         set tagValues to {}
                                         set theRange to "B" & d & ":" & "G" & d
                                         set C to 1
                                         set value of cell C of range theRange to setArt
                                         set C to (C + 1)
                                         set value of cell C of range theRange to setKat
                                         set C to (C + 1)
                                         set value of cell C of range theRange to setProj
                                         set C to (C + 1)
                                         set value of cell C of range theRange to setBetr
                               end tell
              end tell

  • Add row based on previous row in table control?

    Dear all,
    I have a table control with some rows. Every row contains one button. On button click i want to add another row with dirrerent data. I want to add content based on button text or another columns (ex text views text,) based on this text view, I have to add row. One button can click any no of times. On every click i want to add row, but desired position and content should be based on button click.  Any help in doing this??
    Cheers,
    Venkys.

    Refer to these old threads referring this table and button problem.
    Adding rows to table
    How to create different rows in table or in ALV?
    and for the current scenario what you can do is ...
    in the eventhandler of the button click .
    find out the row number by using the code to read index.
    then based upon that add the element in the node at the desired position.
    finding the row number
      data indx type i.
          DATA lo_el TYPE REF TO if_wd_context_element.
          lo_el = wdevent->get_context_element( 'CONTEXT_ELEMENT' ).
    indx = lo_el->get_index( ).
    and the adding the element at the desired position say n
        DATA lo_nd_zdealer TYPE REF TO if_wd_context_node.
        lo_nd_zdealer = wd_context->get_child_node( name = 'DEALER' ).
    data ls_str type  wd_this->element_dealer.
       ls_str-id = '00023445'.
       ls_str-name = 'sarbjeet'.
       ls_str-location = 'hosiarpur'.
       ls_str-status = '0001'.
       lo_nd_zdealer->bind_structure( new_item = ls_str
       set_initial_elements = abap_false
       index = n
    thanks
    sarbjeet singh

  • Add and Delete a row in table

    Hi Expert,
    In SAP interactive form OFFLINE Scneario.
    I have a deep structure. In which i am using other structures like kna1, knb1, knvv.
    Now in KNVV is again a deep structure in which i have a table type.
    Now a draged and droped this table type to my layout  so i got a table.
    I Need to have two buttons ADD and Delete, To add and delete a row in table repectvily.
    I saw other threads also but get not do it.
    My table type attribute's name in KNVV structure is VLACT.
    I write following code on click action of ADD button
    data.#subform[0].Button1::click: - (FormCalc, client) -
    VLACT.row.instanceManager.addInstance(1);
    xfa.form.recalculate(1);
    but it shows error msg
    accessor "VLACT.row.instanceManager.addInstance(1);"
    is unknown.
    Also i am not able to see tabel itself wich i draged and droped. Only two buttons are there.
    Plz help
    Thanks ? Regards,
    Arvind

    Hi Otto,
    This is the code i am using to add new row.
    Also all the settings in form are correct like "Repeat row for each data item" etc.
    I want to have at most 7 rows.
    var nTableLength = Table1.nodes.length; 
      var nNumRow = 0;
        for (var nCount = 0; nCount < nTableLength; nCount ++)
          if ((Table1.nodes.item(nCount).className == "subform") & (Table1.nodes.item(nCount).name !== "HeaderRow"))
           { nNumRow = nNumRow + 1; }
               if (nNumRow == 7)
               { xfa.host.messageBox("The maximum allowable number of rows is 7. You cannot add any more rows.", "Warning", 3); }
           else {
                  Table1.Row1.instanceManager.addInstance(1);
                  xfa.form.recalculate(1);
                   xfa.host.messageBox("row added" );
    I get the msg form the statment        xfa.host.messageBox("row added" );
    But i can not see the newly added row
    Plz help
    Thansks & Regards,
    Arvind

  • Adding/removing rows in TABLEVIEW

    Hi. I've got a TABLEVIEW in one of my subscreens. But when load itab into that tableview with 'LOOP AT...'  tableview appears but I can't add rows to it. I can't delete existing rows too. What should I add to my programm to have possibility of adding/removing rows from my tablewiev? Greetings. P.

    Hi Friend,
    To add/delete rows in your table view.
    You have to add/delete rows from internal table fro where you are displaying values.
    You have to write code in PAI..
    In LOOP ... ENDLOOP check the OK_CODE if it is ADD (for eg.) you have to add a blank row to internal table by just passing a blank work area.
    And if it is DELETE (for eg.) delete the row of that index (TABLEVIEW-CURRENT_LINE)...
    for these two excersies you have to readjust lines of tableview...after taking number of lines from internal table (DESCRIBE TABLE INT_EX LINES WS_LINES
    TABLEVIEW-LINES = WS_LINES) write this piece of code in Intialization.
    Hope it will solve the problem.
    Regards
    Krishnendu

  • To Update rows in Table in OA Framework

    Hi All,
    I have one requirement to update the table.
    For the first time when User opens the form, nothing is stored in database for the user id.
    He opens the form and enter 5 rows and click on save button.So 5 rows get inserted in database. Each record is having unique key which is also the primary key.
    Now user relogin, this time initially inserted 5 records should be displayed and editable by user. Also he should be able to insert new row with unique key.
    After editing, when he again clicks on "Save" button, edted record should get saved in table with same unique key.
    How to achieve this.
    I am able to insert rows in table for the first time. I am not getting how rows will get updated with same unique row. And at the same user should be able to add new row also.
    As for unique row, I am using a sequence which is autoincremented for each row insertion..
    Please can anyone help me in this regard
    Thanks in Advance

    Hi Tapashray,
    Thanks for help..
    My requirement is same as what you said...
    Lets say I have one table with column as Emp_id, emp_name,address, phone_no.
    Emp_id is sequence which is auto incremented each time a row is added in table.
    Other fields are user enterable.
    Say for ex Manager logs in and create 4 employees for which emp_id auto generated as 1,2,3,4.
    He has entered other details through screen. When he clicks on "Save" buton, all details get saved in database.
    Now when he logs in again, he should be able to see all details of 4 employees and details should be editable.
    Now suppose he change the emp_name column of first employee with emp_id =1 and clicks on "Save" button, then a row in database should get update with same emp_id =1.
    Also on the screen, he should be able to create new employees with new and next emp_id.
    Hope you got my requirment.

Maybe you are looking for