Dynamically changing dropdown options in JCombox cell editor

Hi all,
I have a JTable with one column with JComboBox renderer and i am using the cell editor for that column as new DefaultCellEditor(JComBoBox renderer class).
My requirement is i want to change the dropdown options basing on another column value.
So what i did is in the setValueAt(...) function i got the table column renderer and as send the new values in a object to the renderer and in the getTableCellRendererComponent method i am checking the row number and setting the dropdown options to the JComboxBox. This works fine and the JComboBox is showing the new dropdown options correctly but when i click on the JcomboxBox cell it is showing the old dropdown options.
So my question is how can i change the values in the editor.
I tried like this in my setValueAt(..) functioin in my JTable model
( (my custom class) ((DefaultCellEditor) table.getColumnModel.getColumn(int)).getComponent).add(NewObject)
in the new object i am sending new dropdown values and row and column but it some how it is updating renderer but not editor. Please give me the solution
Thanks in advance
Sunil

You can extend DefaultCellEditor the same way as you extend cell renderer.
After that you can set it back to your table using table.setCellEditor() method.
best regards
Stas

Similar Messages

  • Dynamic changes of option tags in a Select tag using JavaScript

    I got this problem during my project.
    I used Select tag in HTML code.
    I have to change options related to Select tag, based on events.
    How can we change options dynamically using JavaScript?
    Please post solution to this problem..

    You know Sun Java Studio Enterprise forum isn�t a right place for JavaScript & HTML questions.
    BTW here is you can find a lot of js stuff: docs, samples, tutorials, etc:
    http://www.w3schools.com/js/default.asp

  • Dynamically change the cell editor in the table control

    Hi..
         I have 3 columns in a table . of which in one column we need to change the cell editor dynamically at runtime.
    i.e for example i have  columns as carrid, connid and fldate.
    For the first 2 rows the cell editor for the carrid  clomn shud be a dropdown and from there on in the next rows for the same  carrid column it shud be a input field.
    Can experts plz help me how to achieve this as this is very high priority issue....
    Regards,
    Madhu...

    This is actaully fairly simple to do.  You will need to add a cellVariant to your table column. You can then dataBind a context attribute to the selectedCellVariant property of the column to control which cellVariant will be used. This allows you to control row-by-row which cell editor you want to output.
    http://help.sap.com/saphelp_nw70/helpdata/EN/bd/5d9041d3c72e7be10000000a1550b0/frameset.htm
    http://help.sap.com/saphelp_nw70/helpdata/EN/56/5e9041d3c72e7be10000000a1550b0/frameset.htm
    Also here is an example that I did the other day that uses Cell Variants within ALV.  This process is actually a little more complicated because you have to go through the ALV APIs.  To do this in a normal table is actually easier because you can create the cellVariant in the layout designer.
    Re: Freely-programmed value help for a single ALV cell

  • Table UI element - dynamic cell editor change on runtime

    Hello,
    I have standard table UI element defined on one of the views as part of it's layout, two columns only - KEY and VALUE. Both defined as text cell editor by default. Content of the table is dynamic and different combination of keys and values are presented depending on the app context.
    Recently the need arised to (depending on the key value) change the cell editor type for single rows only, dynamically from text to link to action - and to register a triggable event for that with some logic behind (to open new window when link is clicked).
    Is it possible at all to have a column in Table UI element with different editor types set dynamically on runtime for different rows? Some cells then wolud still be presented as text, some would have a link to action in them.
    If possible can I ask for any hints on how to achieve that?
    I imagine that first I have to get somehow a reference to the UI element created when the view is triggered first time, then after I recieve values from backend but prior (or after?) binding it to the table context I would like to evaulate the keys and change cell editors accordingly. Then for changed editors (link to action) I would like to register triggable events (on action) which would call some custom methods for further processing. Please advice.
    Best regards,
    Marcin

    Hi,
       You can use the cell variants to display different cell editors in different rows.
       First in your table column where you want to display different cell editors insert two cell variants
       and fill the VARIANT KEY for each cell variant and insert textview under one cell variant and input field
       under another cell variant, and bind the text to be displayed to these cell editors, now take an extra
       attribute of type string in your node and bind it to the table column property SELECTED CELL VARIANT.
       Now depending on your requirement change this attribute to any of the VARIANT KEY defined for cell variants. 
    loop at itab into wa.
          if 'YOUR CONDITION'.
            wa-cellvar = 'VAR1'.                 "cellvar is the attribute which is bound to SELECTED CELL VARIANT
            else.                                          " of table column
              wa-cellvar = 'VAR2'.                 " VAR1 and VAr2 are the variant keys of cellvariants
              endif.
              modify itab from wa.
          endloop.
    Hope this solves your problem.

  • Dynamically change cell properties in a table

    Hi,
    I have read all forum posts about changing table cell properties, but I can't find the solution to my problem.
    I have a table that derives its structure from a table which is the output of an RFC.
    The rows are provided by the model.
    When displaying the result of the RFC call, I want to add a colored row between certain sections with totals of that particular section.
    I managed to add the row in the appropriate place, however I cannot change the color of this row (or even better: the particular cell).
    Can anyone tell me how to proceed? And what property determines backgroundcolor of a tablecell? TextViewSemanticColor determines the text color, I want to change the background color.
    Here is a fragment from my wdDoModifyView:
    i=0;
    IPrivateResultView.IEp_OpportunitiesNode node = wdContext.nodeEp_Opportunities();
    while (i<node.size()) {
         total1 += <some value>;
         total2 += <some value>;
         if (<start of new section>) {
              IPrivateResultView.IEp_OpportunitiesElement el = (IPrivateResultView.IEp_OpportunitiesElement) node.createElement(new Zopportunities());
              el.setAttributeValue("Exp_Revenue", new BigDecimal(total1));
              el.setAttributeValue("Chancevalue", new BigDecimal(total2));
    //     totals row is added here:                    
              node.addElement(i, el);
    //     how can I make this work for background color?
              el.node().getNodeInfo().addAttribute("TextViewSemanticColor", "ddic:com.sap.ide.webdynpro.uielementdefinitions.TextViewSemanticColor");
              el.setAttributeValue("TextViewSemanticColor", WDTextViewSemanticColor.NEGATIVE);
              total1 = 0;
              total2 = 0;
         i++;
    Thanks in advance,
    Roelof

    Hello Knibbe,
    One can play with the readOnly of table cell editor (Input Field) to acheive the expected result.
    Let us take a specific case where your table has four columns say col1, col2, col3, col4 and each of these columns have Input field as the table cell editor.
    Then depending upon the condition specified below choose your option.
    <u>If you have bound the table to the model node</u>
    1. Create a new value node and create a bolean value attribute under it.
    2. Set the cardinality of the value node to 1:1 and singleton to false.
    3. Bind this attribute to the Table cell editor <b>(Inputfield)</b> in col1, col2, col3 and col4.
    4. set the value of this attribute to TRUE when the table gets filled up initially i.e for the elements/rows in which you want to display the total, as per your requirement.
    5. set the value of this attribute to FALSE for the other rows where you want the user to edit the data.
    <u>If you have bound the table to a value node</u>
    1. Create a value attribute of type boolean under the value node and follow the ONLY the steps 3, 4 and 5
    Please reward appropriate points.
    Bala
    Message was edited by: Bala Krishnan

  • How to add cell editor to cell variant dynamically?

    Hi everyone,
      I'm developing a web dynrpo component. In one of the views , I need to modify the view dynamically
    because the data structure only can be determined at runtime. And the table column should have two
    cell variants. I don't know the exact cell variant class which should be used. I only find an abstract class about cell variant CL_WD_ABSTR_TABLE_CELL_VAR , but I can't find any method in this class which
    can add cell editor under this cell variant.
    Thanks in advance.

    Hi Sireesha,
    Thanks for link you provided.
    I am able to add Column with CommandImageLink.And onclick of that link i am able to display another popup.
    Now another problem which i am facing is when i select one row from popup and click "Ok" i have to modify some columns from Dyanamic table which is displayed on main page.
    For this.
    1)First i took the selected row from dyanamic table to update that perticular row depending upon the row which i select from popup.
    if you see the code above i am refaring the list as collection for data.So i am updating that collection but again it is refreshing to it's original value.
    because number of times getList() method of bean get's called equal to number of columns. which brings the values from database.
    Here On click of popup's Ok button I don't want to save the data for table i just want to show there in some column's .and After click on SAVE button from table i have to save it.
    Let me help how can i modify the Dynamic table's data.
    Thanks for all help.
    Jaydeep

  • Changing the event that starts JTree cell editor

    I've implemented a JTree that uses a custom cell renderer and editor. Everything is going well except for a look and feel issue. When I double click on a JTree entry or single click on a node that has already been selected, the cell editor starts immediately. This is way to generous, and I'm finding I'm often editing cells when I just want to navigate the tree.
    I'd much prefer to have the edit event be something harder to do like a right click or a triple left click. Is there a way to change the event that starts the JTree cell editor?

    DefaultCellEditor provides a method boolean isCellEditable(EventObject anEvent), by default it always returns true. Override that method in your cell editor to only return true if the event is a right click, or whatever you want.

  • Theme Editor: where to change backgroundcolor of editable table cells?

    Hi all,
    I need to change the color of an editable table cell.
    I navigated to the theme editor --> tables.There is a section "Editable Tables". The preview shows an example with three columns and tree rows. I want to change the backgroundcolor of the cell in the first row, third column (in SAP standard it is lightgrey).
    The backgroundcolor of the rows beneath can be changed in section "Selected Cells", the backgroundcolor of the first two columns in the first row can be changed by "Background Color of Standard Table Cell" but I can't find the field where I can change the color of the last cell.
    Best regards,
    Sandra

    Hi,
    The blue color come from your definitions on "Labels and Fields" to read-only color of input field.
    Regards,
    F.F

  • Merging of 2 Cells in WD ABAP ALV Header & Dynamically change the header

    Hello Experts,
    I have two main requirements with respect to WD ABAP - ALV report creation
    1) Two feilds in the  header of ALV GRID created in the WD ABAP screen must be merged as shown below(Month Column) ,
    |     January         |     February         |  
    |   Col 1 | Col2      |   Col 1 | Col2        |     
    2) The header value(Month) should dynamically change based on the current date.
    For Eg: If June 2011 is the current month , the ALV table should start from June 2011 and displayed till May 2012.
    Looking forward for your valuable inputs @ the earliest
    Regards,
    Sriram

    Hi Sriram,
    For merging..
    Pleaese go through this
    Merge of Cells in ALV table in ABAP webdynpro.
    ABAP WD: ALV merge cells
    For Header Change..
    How to set title/text for ALV table column header in WD ABAP
    Change column header in ALV to another DDIC Element type
    Change label of a column in ALV
    Cheers,
    Kris.

  • Dropdowns as table cell editors

    Hi
    Does anyone know how to use dropdowns as table cell editors.  I need to create a table where some of the columns have dropdowns as the editor and some don't. 
    I can create the dropdown(by index) by binding a node to the table(the DD list) and binding a subnode-attribute as the text val but that gives me the same list in all rows.  As this is bound to the table and not the column all drop downs would have the same data in the DD list

    Here is what we do for dropdowns that need different values according to the selected row.
    1. Use a DropDownByKey as the table cell editor.
    2. Use the getModifiableSimpleValueSet() API call to modify the values attached to the dropdown on every row selection event.
    We don't have the case where you wouldn't actually have an editor, but you can disable the dropdown if the list is empty, which accomplishes the same effect.
    Beware that if your keys and values are different, the keys not in the current dropdown will not show up correctly on the other rows.

  • Change semanticColor of cell editor

    Hi Experts,
    I have a table and depending on the values of a particular field I want the color of the cell editor to change in one of the columns. How can I achieve that. The table has values populated at run time depending on the inputs from the user.
    Regards,
    Abdullah

    hi abdhullah.......
           bind the cell design property of the column to an attribute of type string and pass number like '2' to it to change the colour at runtime.
    ---regards,
       alex b justin

  • PLEASE HELP-JTable cell editor-change one cell, changes all cells of column

    for example i have 3 rows 4 columns, column 3 and 4 are dates. now if i change the date to a new value (eg for of column 3)
    for any row, and then i click on any other cell. All cell values ie all rows for that column are changed to that new value.
    ie it changed column 3 for all rows 1, 2 and 3 to that new value which i changed in only one cell of that column.
    PLEASE HELP me , tell me what change i make to the code to fix it ....
    this is my cell renderer for date
    class DateCellRenderer extends JbcDateTimeChooser implements TableCellRenderer {
      protected Border m_noFocusBorder;
      public DateCellRenderer() {
        super();
        setStylePattern(JbcDateTimeChooser.MEDIUM);
        m_noFocusBorder = new EmptyBorder(1, 2, 1, 2);
        setOpaque(true);
        setBorder(m_noFocusBorder);
      public Component getTableCellRendererComponent(JTable table,
       Object value, boolean isSelected, boolean hasFocus,
       int row, int column)
      if(value instanceof Date) {
          Date b = (Date)value;
          setDate(b);
        setFont(table.getFont());
        setBorder(hasFocus ? UIManager.getBorder(
          "Table.focusCellHighlightBorder") : m_noFocusBorder);
        return this;
    }I have this custom cell editor date
    class DateCellEditor extends AbstractCellEditor implements TableCellEditor {
      protected JbcDateTimeChooser editor;
      public DateCellEditor() {
        super();
        editor = new JbcDateTimeChooser();
        editor.setStylePattern(JbcDateTimeChooser.MEDIUM);
      public Object getCellEditorValue() {
        return editor.getDate();
      public Component getTableCellEditorComponent(JTable table,
       Object value, boolean isSelected, int row, int column)
        if(value instanceof Date) {
          editor.setDate((Date)value);
        return editor;
    }and this is how i defined in jtable
        lnnTableModel = new CellSiteLNNTableModel();
        lnnTable.setModel(lnnTableModel);
        lnnTableModel.addColumn("ABC");
        lnnTableModel.addColumn("DEF");
        lnnTableModel.addColumn("Date From");
        lnnTableModel.addColumn("Date To");
        for(int k = 0; k < lnnTableModel.getColumnCount(); k++) {
          TableColumn col = lnnTable.getColumn(lnnTableModel.getColumnName(k));
          TableCellRenderer renderer;
            DefaultTableCellRenderer textRenderer = new DefaultTableCellRenderer();
            renderer = textRenderer;
          TableCellEditor editor;
          JTextField textColumn = new JTextField();
          if((k == CellSiteLNN.DATE_FROM) || (k == CellSiteLNN.DATE_TO)) {
            editor = new DateCellEditor();  //  this is the cell editor
         renderer = new DateCellRenderer(); // this is the assigned cell renderer
          } else {
            editor = new DefaultCellEditor(textColumn);
          col.setCellRenderer(renderer);
          col.setCellEditor(editor);
        }

    table model is extended from AbstractTableModel
    and have these methods
    do you see anything wrong here.....
      public Object getValueAt(int row, int column) {
        Vector rowVector = (Vector)dataVector.elementAt(row);
        return rowVector.elementAt(column);
      public void setValueAt(Object aValue, int row, int column) {
        Vector rowVector = (Vector)dataVector.elementAt(row);
        rowVector.setElementAt(aValue, column);
        // generate notification
        fireTableChanged(new TableModelEvent(this, row, row, column));
      } // end method (setValueAt)

  • How to change the colour of the table cell editor on some condition?

    Hi all,
    I have a requirment acco which i need to make the colour of the tableceleditor ias RED and font color white when the data in that is < 0.please tell me how is this possible and its urgent..
    regards
    Sharan

    If you are using release NW04 and have a TextView as table cell editor, you can do this:
    Add a calculated attribute "Color" of DDIC type "com.sap.ide.webdynpro.uielementdefinitions.TextViewSemanticColor" under the data source node of the table.
    Bind the "semanticColor" of the cell editor to this context attribute.
    Implement the get-method for the calc. attribute like this
    WDTextViewSemanticColor get<DataSourceNode>Color(I<DataSourceNode>Element element)
      return element.getValue() < 0 ? WDTextViewSemanticColor.NEGATIVE : WDTextViewSemanticColor.STANDARD;
    Armin

  • How to use the cell editor in FICO reports for YTD

    HI experts,
    I am working with BI7.0, in the below report, i have displayed result based on user input.but how to calculate the YTD values. User will give the input like 072007, results will be display one year from 072007 to 062006 (one yearback) and one more column is YTD
    Report structure is :
         user input(single value): 072007
              AUG06....JAN07....JULY07....YTD
    KEYFIGURE-1        453      -
    777     -
       232       -
      777 (Only Jan07 value of Keyfigure-1)   
    KEYFIGURE-2        879      -
    233        -
    123       -
      ???? (only sum from Jan07 to July07)
    KEYFIGURE-3        212            -
    879      -
    989                -
    KEYFIGURE-4        234            -
    656      -
    788                   -
    KEYFIGURE-5        345            -
    878      -
    878                 -
    KEYFIGURE-6        767            -
    767       -
    323                 -
    KEYFIGURE-7        879            -
    878     -
    999                -
    999 (Only last value of keyfigure-7 (July07)
    in the above report, total 7 keyfigures so 7rows of YTD column
    1) in the first YTD column, how will display only one value (keyfigure-1) of Jan07?
    2) in the last YTD Column, how will display only one value (keyfigure-7) of July07?
    3) from 2 to 6 columns of YTD, how will display the sum from Jan07 to July07?
    Note: months will be changed based on user input(single Value)
    how can use cell editor for above the senior.
    if any option is availabel please let me know
    Thanks
    kishore

    I think the following should work:
    Context:
    Rows (node,c=0:n)
    --- rowIndex (integer)
    selectedRowIndex (integer)
    Bind the "selectedKey" property of the radio button (cell editor) to attribute "selectedRowIndex" (outside table data source node) and bind "keyToSelect" to attribute "Rows.rowIndex". Make sure that the "rowIndex" attribute will contain the index of the node element in node "Rows".
    Armin

  • How can one resize a cell editor when in use in a JTree?

    It is possible to resize, for example, a JTextArea cell editor while it is being used in a JTable by having a document listener check the preferred height and then changing the rowHeight of the table to fit that. This gives the nice effect of the table expanding and contracting in size as required while it is being edited.
    I would also like to this this for a Jtree. But one cannot reset the height of an individual JTree row, and although it can be set up to get the correct height when the editor or renderer is installed (via setRowHeight(0)), there does not seem to be a way to dynamically adjust this height while editing.
    This would be very nice to be able to do. (I would say it should be required of a good tree component that it allow this).
    Is there some way I am missing? It seems like there is no difficult constraint on the design of Jtree which should make this difficult in principle.

    You cannot download apps from another country's store unless you have an account in that country which means having a credit card that is tied to a physical address in that country.
    AFAIK, you cannot add more dictionaries to the collection that. Apple has provided. There is no way to add any plug ins, or enhancements to any of the built to in apps or iOS functions.

Maybe you are looking for

  • Accounts Payable Line Item Extraction to BW from SAP using Business Content

    Hi, I have to set up the AP Line Item extraction into BW using the Standard Business Content. Could someone please gide me through the process for doing it ( Step-by-Step if possible), both from the SAP R/3 side and the BW side. Any help deeply appre

  • Error Message while installing Reader 9.4

    I am currently using Windows XP and am getting the following error message when installing Adobe Reader 9.4: Error 1402. Could Not open Key: HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Run\OptionalComponents\MSFS. Verify that you hav

  • GarageBand won't initialize

    I installed GarageBand from the OS X DVDs that came with my MacBook. None of the other iLife applications are installed. When I try to open the program, it doesn't even make it to the initializing screen -- it just goes straight to the error screen w

  • No tuner hardware detectet- HP Pavilion dv6-1244tx with Integrated TV Tuner

    i bought HP Pavilion dv6-1244tx with Integrated TV Tuner. When i go to Windows Media Center->TV+Movies->set up tv receive the folowing message: "The TV signal cannot be configured because no tuner hardware was detected..." Same think with HP Media Sm

  • Scaning - how to scan larger than default setting?

    I have Mac OSx 7 and a hp6600 cz155a printer/copier/scanner.  How do I make the scanner scan a larger area? It cuts off the images and I would like to set a larger area to be scanned. I have a 6600 hp All-in-One scanner. Thanks for any help.