IsCellEditable() to disable cell editing for specific columns

Hello experts:
My SSCCE for this question is at the below link:
http://forum.java.sun.com/thread.jspa?threadID=5293914&messageID=10244030#10244030
My question is how do I disable cell editing for all but the "Price" column of my table in the SSCCE. I tried adding the below lines of code right after creating the JTable. But get compilation errors.
//Here is the block of code that I am trying to include.
     @Override                                                       
     public boolean isCellEditable(int row, int col) {     
     if (col == 7) {                                                  
               return true;
          } else {
               return false;
     } //Below is the method in detail03.java showing the block of code added
private JScrollPane BuildEmptyTable() {
     model = new DefaultTableModel();
     model.addTableModelListener( this );
     model.setColumnIdentifiers(new String[] { "SKU","Qty", "Price"});
        tblDetailTest = new JTable(model);
     @Override                                                       
     public boolean isCellEditable(int row, int col) {     //     <----- I tried placing the
     if (col == 7) {                                        //                  the code block here
               return true;
          } else {
               return false;
     tblDetailTest.setRowHeight(20);
     tblDetailTest.setPreferredScrollableViewportSize(new Dimension(900, 100));
     JTableHeader tblHdr = tblDetailTest.getTableHeader();
     tblHdr.setBackground(Color.yellow);
     JScrollPane scrollPane = new JScrollPane(tblDetailTest);
     return scrollPane;
}Can somebody please guide me? Thank you very much.

oops!
Sorry, my bad! I did not tell you what I tried. Following your suggestion, I made the following 2 changes to the code:
In the method, BuildEmptyTable(), where I build the table structure, I have the following statement:
     tblDetail = new JTable(model){
public boolean isCellEditable(int row, int col) {
       return col == 8;
};And in a separate method after the table is populated with data, I have the below code:
     tblDetail.getModel().addTableModelListener(new TableModelListener() {
     public void tableChanged(TableModelEvent e) {
     if (e.getType() == TableModelEvent.UPDATE)
          int row = e.getFirstRow();
          int column = e.getColumn();
             if (column == 8){
               //code here
               System.out.println("Updating item price!");
     }I do understand that the message gets displayed as many number of times equal to number of rows inserted into the table, because of the UPDATE event. But my problem is I do not know how to make a code change to do what I exactly want, as I have indicated in my previous note. Meaning I want the listener to be called only when the
data in the editable cell changes.
Thank You.

Similar Messages

  • JTable - disable cell editing for whole table

    I need to know how to disable cell editing for the whole of a JTable. Is there an easy way of doing this??

    you can do it very easy :)
    just override AbstractTableModel's isCellEditable(int row, int col) function
    and return false is ok.
    Hope this helps!

  • ALV Row Editable for specific column

    Hi,
      I am creating a transaction using ALV  - Webdynpro. I would like to enable or disable the row ,(specific column in that row ).
    Problem is very similar to the thread posted in the below link.
    enable or disable row in alv
    Please let me know how to achive the scenario.
    Thanks,
    Kumar

    Hi Kumar,
    Have a look at [this thread|How to set some rows in ALV to be editable or some non editable.; in which I have given the complete code to solve your problem. There is one post which explains how to set the cell editor, and one more post explains setting the cell as editable or read only.
    You need to bind the read_only property of your node attribute (i.e, whichever column you want this behavior on), to another attribute (say FLD_READ_ONLY) in the same context node. And based on the value in attribute FLD_READ_ONLY, the cell property would be changed. Define this attribute of type char01. So based on your business logic, if you want the cell to be read only, set X in the attribute, and if you want it to be editable, set space.
    I hope that would be clear enough. Please revert for any clarifications. Depending on your requirement, if you want the read_only property to change on lead selection, you can get the lead selection index and set the attribute FLD_READ_ONLY = X / space only for that element. This would make only one cell editable at a time.
    You could also refer to this recent [thread|ABAP WebDynpro: Can edit a cell in a column?; for the same issue, where you would have some additional pointers.
    Regards,
    Nithya

  • Disable cell editing

    Hi.
    Can I disable cell editing in a JTable without using a TableModel and still let the user click on different cells?
    /lars

    You can subclass JTable and override isCellEditable().

  • How to disable an alert for specific time period in SCOM 2012 R2

    Hello,
    Is there any option to disable an alert for specific time period in SCOM 2012 R2
    Regards,
    angs

    No. But you can use the scheduler module in your rule or monitor, which will dictate when the workflow will actively run on the agent - hence disabling alerting for that time period.
    http://msdn.microsoft.com/en-us/library/ff453828.aspx
    Jonathan Almquist | SCOMskills, LLC (http://scomskills.com)

  • Showing Sub-Totals only for Specific Column in PowerView

    Hi,
    Is there a way of showing the sub-totals only for specific columns in a PowerView Matrix?
    I am only aware of showing the sub-totals for all or non of the columns.
    Thanks and Regards,
    Justin

    Hi Justin,
    According to your description, you want to get sub-totals specific columns within columns group. Right?
    In this scenario, we can use IIF() function in expression to achieve your goal. The expression will only return the total value when the column value is a specific value, otherwise we can make it return nothing. Try the following expression:
    IIF(Fields!Column.Value="[specific value]",Sum(Fields!Total.Value),nothing)
    We have tested this scenario in our local environment. Here are screenshots for your reference:
    Reference:
    Expression Examples (Report Builder and SSRS)
    If you have any question, please feel free to ask.
    Best Regards,
    Simon Hou

  • Table Control: Disabling editing for a column

    Hi everyone. Greetings from Buenos Aires, Argentina.
    First of all, I want to apologize for this question in case of it has already been made. The forum is too large to read it completely and I really need the answer, if any, to my trouble.
    I have a table control inside a screen. In it's PBO, I coded a module to change the table control attributes. I declared a work area like the line of the table control's control in order to loop it. I mean this:
    In the TOP of Table Control (I made it by using the wizard) I have this:
    CONTROLS: TC_1 TYPE TABLE VIEW USING SCREEN dynpro_number)
    And in the PBO module I have typed the following:
    MODULE control_change_attrs OUTPUT.
    DATA: wa_tc_1 LIKE LINE OF TC_1-COLS.
    LOOP AT TC_1-COLS INTO wa_tc_1.
    ENDLOOP.
    ENDMODULE.
    In the (...), I have put code with such a logic that, depending of the contents of certain fields in the dynpro, it will hide (or not) some columns of the Table Control. This part is made correctly.
    This logic, also makes (or should make) the table control to disable the input of a column, depending wether a flag is active or not. This flag is activated in other screen's PAI, which is called depending on the contents of the sy-ucomm field of this screen (the one with the table control).
    The (...) is something like this (I'll omit some parts):
    IF wa_tc_1-screen-name = 'COLUMN_TO_HIDE'.
       IF gv_flag = 'X'.
          wa_tc_1-screen-input = 0.
       ENDIF.
       MODIFY TC_1-COLS FROM wa_tc_1.
    ENDIF.
    In a PAI module of this screen, I have coded the following:
    MODULE user_command INPUT.
    CASE gv_ok_code.
       WHEN 'RUN'.
          PERFORM RUN.
        WHEN ...
    ENDCASE.
    END MODULE.
    And in the RUN subroutine, obviusly among other things, I have this:
    CALL SCREEN 0150 STARTING AT XX YY.
    In a module in the PBO of the screen 0150, I clear gv_ok_code. In a PAI module, this is what I have put:
    CASE gv_ok_code.
       WHEN 'ACCEPT'.
          gv_flag = 'X'.
          CLEAR gv_ok_code.
          LEAVE TO SCREEN 0.
      WHEN ...
      WHEN ...
    ENDCASE
    The thing is, when the contents of gv_ok_code is 'ACCEPT' and therefore the flag is activated, then the 0150 screen's PAI finishes and the previous screen's PBO is processed, I know for sure (by the mean of the debugging mode) that the table controls's atrributes are correctly modified, and the most important thing, they stay like that... But, the column desired does not gets disabled, at least not until the NEXT PBO (I mean, it gets disabled when I press the Enter key).
    Why is happening this?

    Thanks a lot for the response, Max.
    I' ve been testing your answer. When I implemented the code that you suggested, after the first PAI, the table control's columns appear as I want.
    The thing is, in order to test if the changes in the columns are reflected in the screen after the call of the dynpro no. 0150 (and the obvious return to the first one), I need to be able to select one or more table control's rows (since when I followed the table control wizard, I made it with selection column, and with multiple selection). But, after implementing your code, I'm not able any longer to select any rows.
    I click on them, but they don't turn yellow. I commented the call of the module inside the LOOP AT itab... of the PBO and I was able to select them once again, so we're sure the problem is caused because of the call to this new module. But why?
    Note: you should know, since the table control is with multilpe selection, the LOOP sentence in the PBO is like this:
    LOOP AT itable
           INTO work_area
           CONTROL tc_1
           WITH CURSOR tc_1-current_line.
    MODULE change_attribs.
    ENDLOOP.
    Does that give a hint to you?

  • Web Dynpro ALV disable column sort for specific column

    Hi,
    I have the above mentioned problem. The Coding I use is:
    DATA:  lr_field_settings  TYPE REF TO if_salv_wd_field_settings,
                lt_fields          TYPE SALV_WD_T_FIELD_REF.
    FIELD-SYMBOLS:  <fs_field>  LIKE LINE OF lt_fields.
    lr_field_settings ?= lr_config.
    lt_fields = lr_field_settings->get_fields( ).
    READ TABLE lt_fields ASSIGNING <fs_field> WITH KEY fieldname = 'ANSPRECH_DETAILS'.
    IF sy-subrc EQ 0.
      <fs_field>-r_field->if_salv_wd_sort~set_sort_allowed( abap_false ).
      <fs_field>-r_field->if_salv_wd_sort~set_grouping_allowed( abap_false ).
    ENDIF.
    When debugging I can see that the object attributes for sort_allowed and grouping_allowed are changed from 'X' to ' '
    but the running application still allows sorting and grouping for the column 'ANSPRECH_DETAILS'.
    So what did I forget or what is my mistake ????
    Thx for your help.
    Dino Dini

    I got the similar requirement and I tried to do the below way.. it worked for me..
    DATA: lr_field_settings TYPE REF TO if_salv_wd_field_settings.
    DATA: lr_field TYPE REF TO cl_salv_wd_field.
    lr_field_settings ?= lr_table.
    lr_field = lr_field_settings->get_field( 'MATNR' ).
    lr_field->IF_SALV_WD_SORT~SET_SORT_ALLOWED( abap_false
    you can observe in the below image that sort option is not enabled for MATNR in the ALV.

  • Disable esmtp Inspection for Specific Host

    Hello.  Is it possible to disable esmtp inspection for a specific INSIDE host with use of a policy-map?  If so, could you provide an example configuration.
     

    Yes it is possible.  You could do something like the following:
    access-list ESMTP deny ip host 1.1.1.10 any
    access-list ESMTP permit ip 1.1.1.0 255.255.255.0 any
    class-map CMAP
    match access-list ESMTP
    policy-map PMAP
    class CMAP
    inspect esmtp
    service-policy PMAP interface inside
    Please remember to select a correct answer and rate helpful posts

  • Disable Websense scanning for specific src networks

    Hi all,
    I have an installation of Forefront TMG 2010 with Websense Web Filter Plug-In. The task I am supposed to do is to disable redirecting requests to Websense for specific source networks. It is impossible to do it from Websense Server, due to license limitations.
    I know there's a way to ignore some source users from isa_ignore.txt but I should filter this basing on source IP addresses. Please help me solving this issue.
    Kind Regards,

    Hi,
    You could try to create a network for these IP addresses and create a account for this network. Then add this account into isa_ignore.txt.( I haven't tested it)
    Best Regards,
    Joyce
    We
    are trying to better understand customer views on social support experience, so your participation in this
    interview project would be greatly appreciated if you have time.
    Thanks for helping make community forums a great place.

  • Get column value for specific columns

    I want to change the default behavior of a IKM. In a specific step, I need to call a PLSQL procedure inside the loop below, and that procedure will substitute the insert clause. The procedure uses only some attributes, and I need to check the name of each one when I use the getColList method.
         for aRecord in myCursor loop
              insert into      <%=snpRef.getTable("L","TARG_NAME","A")%>
                   <%=snpRef.getColList("", "[COL_NAME]", ",\n\t\t\t", "", "((INS AND (NOT TRG)) AND REW)")%>
                   <%=snpRef.getColList(",", "[COL_NAME]", ",\n\t\t\t", "", "((INS AND TRG) AND REW)")%>
              values
                   <%=snpRef.getColList("", "aRecord.[COL_NAME]", ", \n\t\t\t", "", "((INS AND (NOT TRG)) AND REW)")%>
                   <%=snpRef.getColList(",", "aRecord.[COL_NAME]", ", \n\t\t\t", "", "((INS AND TRG) AND REW)")%>
         end loop;
    For example, to call the procedure I do that: schema.proc_1(col1, col2, col3). However, I have more than 3 columns, and I need to restrict them when I use the getColList method. I would like to know if there is a way to get only specific columns, giving these names. I pass the name of the column, and the method should return its value. Can I use the getColList to do that? Is there any other way to do that?

    Hi Luciene,
    You can use the UD flags to do this. If you click on one of your mappings in the Diagram tab of your interface you will notice several UD flags (UD1 to UD5) you can use those to flag the columns you want to use in proc_1.
    To summarize:
    - at the interface level flag the columns you want to use in your PL/SQL code -> check UD1 for all of them
    - modify your IKM code:
    <%=odiRef.getColList(",", "COL_NAME", ",\n\t\t\t", "", "((INS AND TRG) AND REW AND UD1)")%> <- retrieve columns flagged with insert, not read only, mapped on target and with UD1 flagged. The "AND UD1" part can be used in other getColList.
    Hope this helps.
    Thanks,
    Julien

  • Make a filed Non-Editable for specific Users

    Hi Experts
    Any Idea How can I make fields of any Table non-editable for a specific Group of Users.
    My Requirement
    I have 4 fields namely, Customer Name, Address, Pincode,City which at time of creation is open to user but once updated and customer is created,  I need to make it non-editable for a specific Group of user.
    Please advice.
    Regards
    Prashant

    Hello Neethu,
    I just wanted to confirm one of the sentence in the above post.
    I feel that the option 2 can also be achieved (Once record is approved and gone through all processes of WF and saved in MDM.Specific users should not modify the record.)
    For this we need to create validation where we need to mention the User
    Just create a Status field and write an expression as
    IF(STATUS FIELD [RECORD]=STATUS[DONE] AND UPDATED BY="USER NAME",FALSE,TRUE)
    for this the automatic execution type property should be set to error.
    Only difficulty is that we need to mention all the users for whome we want to remove the write access once the record is saved.
    Rgds,
    Prasad.

  • How to disable drill option for one column in the WebI Report

    Hi,
    How to disable drill option in a column in WebI?
    When the Drill option is enabled by default all the column in the report will have that enabled,
    I ahve added Hierarchy in the Custom hierarhcy list in Universe.
    I am using BOXI3.1 WebI Reports.
    But I wanted only the hierarchy column to have that drill option enabled, rest all column should display text data.
    PLease let me know if you have any idea.
    Thanks in advance.
    Regards

    Cretae the variable at the report level (may be with the same definiton) and then use that variable in the table
    to disable the drill. It will be displayed as normal text object.
    Drill functionality is enabled only on the objetcs coming from the universe.
    Regards,
    Rohit
    Edited by: rohit12 on Mar 11, 2010 10:12 AM

  • Setting different Tabel Cell SemanticColor for Multiple Columns of each row

    Hi,
    I have requirement of setting different colors to different columns for each row based on some condition in table data.
    The data to table is coming from model, hence table is mapped to model node and attributes.
    I have created Seperate Node CellColorNode with attribue CellClr1 and CellClr2 of type TextView Semantic Color.
    Set the calculated, read only attribute to True. Mapped table columns text view to the CellColorNode->CellClr1 and CellColorNode-->CellClr2 correspondingly.
    Now, my query is how do i set the colors to CellClr1 and CellClr2 attributes. As I need to set the color for multiple columns of each table row.
    Is it in method getColorCellCellClr generated? Any  Example Code?

    Its resolved by following below link
    http://scn.sap.com/thread/158286

  • Disable disk sleep for specific drive?

    My Mac Pro is running 24/7 with sleep enabled.
    Hard disks are set to sleep, when possible. One of my SSDs is on an internal PCIe card. With disk sleep enabled, it does not come up quickly enough and the computer keeps thinking, it was ejected. The problem goes away, when disabling disk sleep.
    No sleep is no problem with SSDs, but there are some spinning 4TB disks on the system only used infrequently, so I would like to let them sleep.
    Is there a way to disable sleep for a specific disk only?
    -- Harald

    Hi BahaSs,
    It generally is safe to "Enable write caching on disk" unless you are dealing with broken applications which are not using
    FILE_FLAG_WRITE_THROUGH but need every write to be persistent. Disabling this would not hurt too much.  It's really not recommend "Enable advanced performance" or
    "Turn off Windows write-cache buffer flushing on the device" on a system where you value uptime or require data integrity.
    Best Regards,
    Elaine
    Please remember to mark the replies as answers if they help and unmark them if they provide no help. If you have feedback for TechNet Subscriber Support, contact [email protected]

Maybe you are looking for

  • My iPod touch 4g will not sync for anything!

    I got my iTouch this January and have had horrible problems with it since about a month after I got it. The first problem I had was that certain songs go silent partway through, but the sound starts again about 30 seconds later. It always happens at

  • How do I generate a Certificate Signing Request (CSR)?

    If I buy an SSL in godaddy, how do I generate the CSR? If my site is hosted in BC, who is the web server? I've had a few sites search for the name of the web server and it comes up as unknown every time.

  • Annotating InDesign CS6 pages - Can I use a Wacom?

    Hi, I've got a Wacom tablet which I use to draw and annotate. Can I use it to make quick sketches and notes on top of my work in InDesign CS6? It would be unbelievably quick and useful to be able to get a (raster) pencil and sketch my thoughts on lay

  • For Migration: Staffing of existing Roles with Distribution

    Hi, As a part of Migration, we are trying to use a Report for Uploading Staffing data. The roles are having Distribution. We are trying to use BUS2177staffingadd BAPI which works only if Start and End dates are same as that of Role. We are planning t

  • My timebase does not scroll (in my voltage measurements)

    I have a 5v DC pot connected to my 6008 USB  DAQ. In labVIEW when I run it I get my voltage output as expected but the timebase does not scroll it remains fixed. When I change the axes scales the output voltage still only varies over the first second