Making JTable rows not editable

i need to make a jtables rows and columns to not be editable, but i also need it to be able to be selectable. i know one way to do it is to extend defaulttablemodel and overwrite the iscelleditable method, but the problem is that i'm already extending jframe. is there any other way to do this keeping jframe extended, because i need it to be extended?
thanks for the help

JTable table = new JTable(..){
  public boolean isCellEditable(int row, int column){
    return false;
};

Similar Messages

  • Making some rows non-editable in ALV grid

    hi
    I am using reuse_alv _grid _display to display the output. I want to make some of the rows non-editable based on some conditions. please help.

    Hi Vijay / Manisha / Murugan
    Is this question answered? The link is presently not working.
    I have a same requirement. I am using reuse_alv _grid _display to display the output. After click on 'Add row'
    button, the alv should add a row in edit mode and remaining all other rows in display mode. Is that possible using reuse_alv _grid _display?
    Any kind of inputs regarding this will be damn damn helpful. Thanks.

  • Forecast KF row not editable

    The Forecast KF row in planning Book is not editable. How to make it editable? Is this something controlled by user authorization?
    Thanks

    Hi there,
    You can do this by adding one default macro for ATTRIBUTES of the Forecast Keyfigure. function CELL_INPUT (1)
    0 is display , 1 is editable. Check details on the link provided below.
    http://help.sap.com/saphelp_scm41/helpdata/EN/1d/310eb3d0ee11d4b2e40050da385632/content.htm#CELL_INPUT
    Please confirm if it works for you.
    Regards,
    Pradeep

  • Is there a way to make the current row not editable

    Hi, I'm using JDev 11.1.1.2
    In my usecase I have a Form , navigateable with next/previous , and for every row a I have a calculation which makes the row editable or not.
    For now I made it with disabled property on every input component set to some bean property which is calculated every time.
    My question is if there is some general way to make an Entity not updateable ?
    I tried with doDML() ... but the problem there is that this method is not called when switching the current row but rather when commiting. So the user can modified several rows and when pressing commit it will prevent some of the to be committed which would be confusing.
    Is there a method in the ViewObject that i can overwrite which is called every time the current row is changed? So I can see if the row was modified or not.
    Thanks, agruev

    Yes, there is always isAttributeUpdateable() in the ViewRowImpl, which you can override and enable/disable your attributes based on an enabling/disabling condition.
    Here is an example:
    public boolean isAttributeUpdateable(int i) {
    boolean updateable = false; /disable by default all arguments
    // enable, if your condition is met
    if ( meets_your_condition )
    updateable = super.isAttributeUpdateable(i); // let the framework decide based on your declarative settings
    return updateable; // return true/false indicator
    Nick

  • Af:table new row not editable

    Hi, I am trying to insert and edit a new row in table. I have followed the below steps.
    1. Dropped a vo as a table (not read-only)
    2. surrounded it with a panel collection and in toolbar facet created a toolbar and under which I have dropped createInsert method of
    vo as commandToolbarButton.
    3. set table's editingMode property to clickToEdit and partialTriggers property to commandToolbarButton's id.
    I deployed the application into integrated wls, I clicked on the create button to insert a new row and provided values in all fields then I clicked on some other existing row, now when I clicked on the new row, which was just created, none of the fields/columns are editable.
    Have I missed anything here? Can you tell me how to fix this?
    Thanks in advance

    Thanks for your answer.
    Your solution is not working but if i put the styleclass instruction in the outputText element, it is working...
    Is there any other solution ???... because in this solution, we are obliged to put this EL in each outputText element of the tab.
    <af:column sortable="true" headerText="Cat" formatType="text"
    sortProperty="cat">
    <af:outputText value="#{log.cat}" styleClass="#{(log.prio == 'DEBUG') ? 'bgDebug' : (log.prio == 'WARN' ? 'bgWarn' : '')}"/> </af:column>

  • Ot? making jtable column not enabled?

    I've a jtable with an abstract table model. I can set up the isCellEditable (via the table model) to return false for a given column, but the user can still "tab" into that column or select it.
    Can someone indicate how to set the column as being not "Enabled" so that tab will skip over that column, and the user may not select it?
    TIA

    <BLOCKQUOTE><font size="1" face="Verdana, Arial">quote:</font><HR>Originally posted by kkirk:
    I've a jtable with an abstract table model. I can set up the isCellEditable (via the table model) to return false for a given column, but the user can still "tab" into that column or select it.
    Can someone indicate how to set the column as being not "Enabled" so that tab will skip over that column, and the user may not select it?
    TIA<HR></BLOCKQUOTE>
    Hi,
    Yesterday, when working with a TextFieldControl, I stumbled upon "setRequestFocusEnabled(boolean b)". I you set this to false for the textfieldcontrol, it is skipped when tabbing and you can't get your cursor in it.The method is defined in JComponent.
    Maybe this works with the table?
    I hope this helps
    Lonneke
    null

  • Not editable in JTable..

    I want to make not-editable cell in JTable.
    so I was searching for source code and posts in forums..
    I found perfect source code..
    but I don't know the difference between my source code and perfect code...
    could you explain me the difference two of sources
    Especially, isCellEditabel function....
    In advance thank you
    perfect code
    Test()
    JTable myTable = new JTable(data, headers)
    @Override
    public boolean isCellEditable(int row, int column)
    return false;
    add(new JScrollPane(myTable));
    my source code
    field_vc.add("Hotel Name");
    field_vc.add("City");
    field_vc.add("Maximum");
    field_vc.add("Smoking");
    field_vc.add("Price per Night");
    field_vc.add("Date");
    field_vc.add("Customer ID");
    field_vc.add("Select");
    view_jt = new JTable(data_vc , field_vc)
    @Override
    public boolean isCellEditable(int row, int column)
         return false;
    view_jsp = new JScrollPane(view_jt);
    perfect source code is not editable in JTable
    But my source code is editable in JTable
    Plz help me
    Edited by: KIMJINHO on Feb 22, 2008 8:33 AM

    But my source code is editable in JTableprove it by posting a demo program that we can copy/paste/compile/run and double click a cell to edit

  • Making particular rows as non editable before displaying the TABLE

    Hi everyone,
                               I would like to know how to make a particular rows as non editable in UI element "TABLE" before it is displayed . The scenario is :
    On entering the Personnel number, I am getting family dependants in the table. Then, I am selecting any of the family members on some condition and saving each member with the request.
    Next time when i enter the same personnel number, I would like to show the table with already saved request for the family members rows as non editable & other members row as editable.????
    Please provide a feasible solution.

    Hi Pradeep,
    follow as per suggested. if not work use cell variants concept. it will work.
    Please check this wiki...
    http://wiki.sdn.sap.com/wiki/display/WDABAP/WebDynproforABAPCellVariants
    Cheers,
    Kris.

  • Allow edit only user's rows, not someone else's

    Hello
    as you know the option make Form and Report brings a report editable. Is there any way using that option to modify the report to make it non editable?
    OR
    more interesting, that only the user can edit his own row, not the rows of others. That is, there will be different users logging in separately and each willl be adding a row. is there a way one can edit only his row while he has no access to someone elses ?
    thank you
    Al
    Edited by: Alvaroe on 19-Nov-2009 15:29
    Edited by: Alvaroe on 19-Nov-2009 15:34

    Hi,
    maybe there is smarter way to make it, but I used to do it using CASE statement and javascript. I don't have working code, but that's the idea:
    1. In your report you have column with creator name - you use it in your SQL CASE statement like:
    SELECT some_columns, CASE created_by
      WHEN :APP_USER THEN '<a href="#" onclick="goToEditMode('||report_id||')">EDIT</a>'
      ELSE '-'
      END
    "EDIT" FROM your_tableNow if current user has created specified record, edit link appears in EDIT column.
    2. You must add hidden field (P_HIDDEN) to know which row has been selected to edit and javascript function that submits the page:
    <script>
    function goToEditMode(report_id){
    $x('P_HIDDEN').value=report_id;
    doSubmit('EDIT');
    </script>3. Last thing is to create branch that takes you to EDIT page when 'EDIT' request is sent by javascript function. Don't forget to set P_HIDDEN value to edit page in order to know which record is edited.
    Regards,
    Przemek

  • Selected row not becoming active.

    JDev 11
    In a page fragment
    1. I add an af:panelCollection, drag n drop a table from the Data Controls into the collection, enabling filtering, sorting and row selection.
    2. I create an af:popup, add an af:panelWindow, drag n drop the same table from the Data Controls into the panelWindow creating an ADF Form with a submit button.
    3. I add a toolbar button to the collection in 1, then add an af:showPopupBehavior to the button.
    When I select a row, the selected row in the table is highlighted properly.
    When I click the button, the popup displays but it is always displaying the first record in the table.
    I've tried
    making the table both editable and read only.
    setting to triggertype in the popup behavior to different settings.
    adding partial triggers in multiple places.
    setting the button partialsubmit to false.
    several other random settings.
    blowing away the whole thing and starting over a few times.
    I'm pretty sure the problem is related to the row selection in the first table not setting the current row in the data control, but I'm a newb and not sure how to fix it.
    Any thoughts?

    Figured it out.
    There are couple required selectone lists on the popup that were created wrong so the actual value wasnt in the list and I'm guessing since it is in the same screen it wouldnt let the navigation to other records happen.
    Fixed those and it all works fine.

  • Set JTable to non editable

    Hello,
    I have a one column JTable that I would like not to be editable. How do I set the table not be editable? I am not using a table model. Would that be a problem?
    I am using the folllwing code:
    Vector rows =  new Vector(0);        //create a vector for the rows 
        //add a vector within a vector       
        for(int i = 0; i < 10; i++)       
            //create a new vector and add the values to the vector           
            Vector oneRow = new Vector(0);   
            //fill one row           
            oneRow.add("Row Input"));   
            //add the new vector to the outer vector           
            rows.add(oneRow);       
        }   //add the header to the byte column      
        Vector cols = new Vector(0);       
        cols.add("Values");       
        //create a JTable with one col and rows the size of the byte array       
        JTable myTable = new JTable(rows, cols);

    look at DefaultTableModel it has a isCellEditable(int rowl, int col)
    method which you can override for your own needs.

  • Pls Help :JTable Double Value Editing Problem

    hi friends
    as i am new to swings and Jtable pls help me if u can.
    in the code copied below when i start putting value into the Double column of JTable
    a ( .0 ) is appended at the end which is undesirable it should be like that only when the value is
    something like 22.99 and also i want to limit the double value's fractional part to be limited to 2 digits only.
    if this can be done in my Table model itself so that it will work everywhere i use this model
    Pls tell me what exactly do i need, a custom Cell Editor or Cell Renderer. and whether can i do it in the
    Table Model Defination class or whether i can only do it on the Jtable only.
    guys its so confusing.pls help
    if anyone can send a sample code for achieving this it would be of great help
    import java.awt.*;
    import javax.swing.*;
    import javax.swing.event.*;
    import javax.swing.table.*;
    import java.text.*;
    public class TableProcessing extends JFrame implements TableModelListener
        JTable table;
        public TableProcessing()
            String[] columnNames = {"Item", "Quantity", "Price", "Cost"};
            Object[][] data =
                {"Bread", new Integer(1), new Double(1.11), new Double(1.11)},
                {"Milk", new Integer(1), new Double(2.22), new Double(2.22)},
                {"Tea", new Integer(1), new Double(3.33), new Double(3.33)},
                {"Cofee", new Integer(1), new Double(4.44), new Double(4.44)}
            DefaultTableModel model = new DefaultTableModel(data, columnNames);
            model.addTableModelListener( this );
            table = new JTable( model )
                //  Returning the Class of each column will allow different
                //  renderers to be used based on Class
                public Class getColumnClass(int column)
                    return getValueAt(0, column).getClass();
                //  The Cost is not editable
                public boolean isCellEditable(int row, int column)
                    if (column == 3)
                        return false;
                    else
                        return true;
            table.setPreferredScrollableViewportSize(table.getPreferredSize());
            JScrollPane scrollPane = new JScrollPane( table );
            getContentPane().add( scrollPane );
         *  The cost is recalculated whenever the quantity or price is changed
        public void tableChanged(TableModelEvent e)
            if (e.getType() == TableModelEvent.UPDATE)
                int row = e.getFirstRow();
                int column = e.getColumn();
                if (column == 1 || column == 2)
                    int    quantity = ((Integer)table.getValueAt(row, 1)).intValue();
                    double price = ((Double)table.getValueAt(row, 2)).doubleValue();
                    Double value = new Double(quantity * price);
                    table.setValueAt(value, row, 3);
        public static void main(String[] args)
            TableProcessing frame = new TableProcessing();
            frame.setDefaultCloseOperation( EXIT_ON_CLOSE );
            frame.pack();
            frame.setLocationRelativeTo( null );
            frame.setVisible(true);
    }thank in advance
    jags

    No.
    But further to this try:
    public class MyCustomRenderer  extends javax.swing.table.DefaultTableCellRenderer
              private java.text.DecimalFormat FORMAT_DOUBLE;
              public MyCustomRenderer()
                      FORMAT_DOUBLE = new java.text.DecimalFormat("#, ##0.00");
              public java.awt.Component getTableCellRendererComponent(javax.swing.JTable table, Object value, boolean isSelected, boolean hasFocus, int row, int column)
                        //NB! you could also set foreground/background here to indicate positive/negative values...
                        if(value.getClass().equals(Double.class))//is this a double?
                                double d = ((Double)value).doubleValue();
                                d = (Double.isNaN(d)||Double.isInfinity(d))?0:d;
                                this.setText(FORMAT_DOUBLE.format(d));
                        else//not a double so let's toString() it...
                               this.setText(""+value);
    }then, using code pasted above, specify a new instance of this class as the default renderer in your
    table.....
    :)

  • JTable does not update after fireTableDataChaged

    Hi everybody,
    I have a strange problem here and I don't know how to solve it. In my applet I use a JTable which displays data from a database and uses a customized table model. The JTable has 2 columns and is NOT editable, i.e. you should not be able to change the values directly in the table itself. Instead, a JDialog is opening when somebody makes a doubleclick on a row of the JTable. In this JDialog one can change the data of the selected row and afterwards the JTable and the database should be updated. The database gets updated but not the JTable, although I called myTableModel.fireTableDataChanged()
    When I close (dispose) the screen which contains the JTable and then recreate the screen with the JTable (using new MyScreen(....)), then the changes are displayed in JTable (because the table model requeries the database). But when I update the database AND the table model of JTable (via setValueAt) then the changed row is displayed 3 times instead of just 1 time!
    Do I have to update both, the database and the table model or is it enough to update the database and call myTableModel.fireTableDataChanged() ?
    But as said in the first case the changed row is displayed 3 times and in the second case the changes are displayed not at all. Do you know a solution?
    I attach some code snippets.
    Your help is appreciated very much!
    //should update the table model of JTable
    public void setValueAt(Object aValue, int rowIndex, int columnIndex)
    row = (Vector) data.elementAt(rowIndex);
    row.add(columnIndex, aValue);
    data.add(rowIndex,row);
    //should update the JTable and the database
    if((oldRecipeName.equals(recipeName)) && (oldDesigner.equals(designer)))
    //no data-saving necessary
    currentDialog.dispose();
    else
    //save and close
    tableModel.setValueAt(recipeName,selectedRow,0);
    tableModel.setValueAt(designer,selectedRow,1);
    updateRecipe(); //this is a method which updates the database
    tableModel.fireTableDataChanged();
    currentDialog.dispose();

    dear, dear, dear !
    in the setValueAt() method, u r adding a new line everytime to the vector. u should not add the data, u should replace the data. change the setValueAt() method to
    public void setValueAt(Object aValue, int rowIndex, int columnIndex)
    row = (Vector) data.elementAt(rowIndex);
    row.setElementAt(columnIndex, aValue);
    //data.add(rowIndex,row); don't need to call this. Changes would be reflected in data also.
    ta,

  • How can i choose row to edit in alv report

    hello ,
    i done alv report with one coloumne that can be edit  ,
    in this coloumne i want to choose which rows can be edit
    and which will be close according to event  .
    i saw example program "BCALV_EDIT_02" that show this case
    but stile , i don't understand what is the action that
    do it .
    this is the  part
    IF p_mode EQ 'RW'.
    *§2a.Use attribute CL_GUI_ALV_GRID=>MC_STYLE_ENABLED to set a cell
       to status "editable".
        l_mode = cl_gui_alv_grid=>mc_style_enabled.
      ELSE. "p_mode eq 'RO'
    *§2b.Use attribute CL_GUI_ALV_GRID=>MC_STYLE_DISABLED to set a cell
       to status "non-editable".
        l_mode = cl_gui_alv_grid=>mc_style_disabled.
      ENDIF.
    so what is the part that will close the row for edit ?
    when i add this part in my report all the row is deleted.
    thanks.

    Dakota,
    You can change the settings at runtime.
    What you need to do is to have another column as part of the internal table, that has the data. This column, say, STYLE will refer to LVC_T_STYL. So, this becomes a nested internal table.
    Set the editable flga switched off at Fieldcat and layout level.
    Now, while filling the data in the table, or looping it separately, fill the Styles table for each row accordingly depending on the conditions. So, if you want the entire row to be enabled for editing, there will so many rows as the no. of columns in the inner internal table which is a column of that row.
    col1  col2   Col3  Style
    1     1      2     Col1 -- Style_Disabled
    ___________________Col2 -- Style_Disabled
    ___________________Col3 -- Style_Disabled
    This should solve your problem.
    Regards,
    Ravi
    note : Please reward the posts that help you.
    Message was edited by: Ravikumar Allampallam

  • How to make sure newly created row is editable by default programatically

    Hi All,
    I got a problem with creating new row in single row selection table with on click property enabled for editing mode.
    Function requirement is like: I have Mater-Detail. While creating detail lines, line has to be created with default line number. Eg: Master1 can have line numbers 1,2,3..etc, Master2 can have 1,2,3.. etc.
    In applicationTable for Pattern Create
    Action Listener=”#{CreateAndEditFiscalDocumentBean.createChargeLine}”
    In Table rowSelection="single" and editingMode="clickToEdit"
    Here the problem is:
    When I first come to the page,the first row in the detail table is editable and could able to edit any other row on click . But When I create a new row , I got a new row with line number but it is not editable.
    I want it to be editable on create and previously selected row should be read only. I have tried several ways but nothing is working.
    My observation is, when I call the bean method in Action Listener of application Table in create patteren, I am facing this problem. If I do not call this method, it is working as expected. But I need to call this method because it has to create row with line number.
    I am putting below two scenarios which I have tried. I am not successful in the both the scenarios.
    Could you please help me in achieving expected functionality.
    Many thanks in advance for your time and help.
    Scenario 1:
    Jsff:
    ApplicationTable: createActionListener="#{CreateAndEditFiscalDocumentBean.createChargeLine}"
    Table: rowSelection="single", editingMode="clickToEdit"
    Bean Code:
    public void createChargeLine(ActionEvent actionEvent) {
    FacesContext fc = FacesContext.getCurrentInstance();
    ExpressionFactory factory = fc.getApplication().getExpressionFactory();
    MethodExpression method=factory.createMethodExpression(fc.getELContext(),"#{bindings.createChargeLine1.execute}",String.class,new Class[]{});
    method.invoke(fc.getELContext(),null);
    AMImpl Code:
    public void createChargeLine() {
    ViewObject itemChargeVO = this.getFiscalDocumentCharges();
    ViewObject fiscalDocumentHeaderVO = this.getFiscalDocumentHeader();
    Row toRow = fiscalDocumentHeaderVO.getCurrentRow();
    Row newRow = null;
    Row latestRow = itemChargeVO.first();
    Integer line_number = new Integer(0);
    int numberOfItemLines = 0;
    if (latestRow != null) {
    RowSet rs = itemChargeVO.getRowSet();
    numberOfItemLines = numberOfItemLines + 1;
    if (rs != null) {
    line_number =
    (Integer)rs.first().getAttribute("LineNumber");
    while (rs.hasNext()) {
    numberOfItemLines = numberOfItemLines + 1;
    Row row = rs.next();
    if (line_number.compareTo((Integer)row.getAttribute("LineNumber")) <
    0)
    line_number =
    (Integer)row.getAttribute("LineNumber");
    line_number = line_number + 1;
    newRow = itemChargeVO.createRow();
    newRow.setAttribute("LineNumber", line_number);
    itemChargeVO.insertRowAtRangeIndex(numberOfItemLines + 1, newRow);
    itemChargeVO.setCurrentRow(newRow);
    } else {
    newRow = itemChargeVO.createRow();
    newRow.setAttribute("LineNumber", new Integer(1));
    itemChargeVO.insertRowAtRangeIndex(0, newRow);
    itemChargeVO.setCurrentRow(newRow);
    Scenario 2:
    Bean method changes:
    public void createChargeLine1(ActionEvent actionEvent) {
    Row newLine = ApplicationsTableEventHandler.getInstance().processCreate(getChargeTable());
    newLine.setAttribute("LineNumber", new Integer(1));
    }

    Hi Jerry,
    Please refer to the following blog and check whether you followed all the steps:
    /people/harikrishna.sunku/blog/2008/12/18/work-center-and-navigation-link-creation-in-crm-2007
    You basically need to ensure that your custom work center is assigned to a navigation bar profile; and this navigation bar profile is assigned to your business role.
    Regards,
    Shiromani

Maybe you are looking for