How to fill row colors in TableView

Hi
I have created a tableview and I need to fill different colors for the rows of the table.  How can I do this.  It would be helpful if some sample code is demonstrated.
Regards,
Vijay

Hi Vijay,
Use the styole attribute of the iterator class's RENDER_CELL_START method...
eg. code in RENDER_CELL_START method...
case p_column_key.
  when 'your_column_name'.
      p_style = 'celldesign:POSITIVE'.
For all the possible values of p_style.....referr to <a href="https://www.sdn.sap.com/irj/sdn/wiki?path=/display/bsp/differencesBetweenDESIGN2002andDESIGN2003&">this Wiki Page.</a>
For more on iterators referr to
<a href="/people/thomas.jung3/blog/2004/09/15/bsp-150-a-developer146s-journal-part-xi--table-view-iterators:///people/thomas.jung3/blog/2004/09/15/bsp-150-a-developer146s-journal-part-xi--table-view-iterators
or
<a href="/people/brian.mckellar/blog/2003/10/31/bsp-programming-htmlb-tableview-iterator:///people/brian.mckellar/blog/2003/10/31/bsp-programming-htmlb-tableview-iterator
Hope this helps.
<b><i>Do reward each useful answer..!</i></b>
Thanks,
Tatvagna.

Similar Messages

  • How to Fill two color's

    HAPPY NEW YEAR
    Hi,
    How to fill two color's in cell of jtable.
    Exactly i need to fill Yellow background and on some conditions i need to put Red on Top-Right-Corner of the cell.
    Thank's

    Check you the reply you got in your other posting on this topic:
    http://forum.java.sun.com/thread.jspa?threadID=5119850

  • How Get Alternating Row Colors To Work?

    I've searched this forum, searched online, and followed the directions in the Numbers 3.0 Help, but I just can't get the Alternating Row Colors function to work.  I'm using an iMac and a new Mac Mini, both running Mavericks, on a spreadsheet converted from Numbers '08.  I've seen several screenshots of tables in discussions on this forum that seem to have Alternate Row shading; presumably they were done with Numbers 3.0. So apparently, it can be done.  Need Help!

    Vistan wrote:
    Now I see it!  I did not have any of the Table Style boxes in the upper right cortner of the creen selected...when I choose one, the alternate row colors sudenly pop up.  I'm now experimenting with the Grid Lines and Header &Footer selection buttons.
    Vistan
    Vistan,
    I'm about as sure as I can be that Table Style boxes having being clicked has nothing to do with the Checkbox for Alternating color rows. I've been wrong before, but I can't grasp the logic on this one, and it doesn't happen here the way you describe.
    Jerry

  • [php+mysql] nextensio list: how to change row color based on field content?

    Hi all
    I have a nextensio list on a page.
    is there a way to change the background color of a whore row based on
    a specific field content?
    example I have a field containing the values 0 or 1.
    If the field content is 1 the row background color should be RED.
    ANy suggestion?
    TIA in advance.
    tony

    DataBoundAPI's you can refer to achieve this.
    Search for OLD threads also. Here are some links:
    Can we colour the rows in the column of a table
    Advanced table row font color- result based change.
    Thanks
    --Anil
    http://oracleanil.blogspot.com/

  • In acrobat 9 pro how do you fill a color in a picture?

    Hello Everyone,
    Does anyone know how to fill a color in a picture using Adobe acrobat 9 Pro. Lets say you have a picture in PDF format, that has a picture of a billboard, and that billboard is not really straight, kinda different shape, how could someone leave it in as a PDF and color the bilboard?
    Any help would be great!

    Actually Graffiti it might be able to be done via 'touchup tool' without creating a new PDF. Assuming of course a photo editor like Photoshop is present.
    To the OP: Acrobat is intended as final destination format and not really suitable for editing (although minor changes can be made with the full Acrobat product). It's always best to do the changes to the original document and then make a new PDF making sure you acknowledge proper version control procedures. Changing the PDF means that you now have a PDF that doesn't match the original document.

  • How to change row background when the value was changed?

    hello expers!!
    i need your help...plz help me.
    i want my table row(specific) background changes when the user changed the value in a cell. I am able to know that a value in a cell was changed but the problem is i dont know how to change row color background. I've researched over the internet on how to solve this problem but nothing was found.
    please see the link to help you visualize what i mean. tnx!
    [http://www.flickr.com/photos/28686474@N04/2708299927/]
    tnx in advance!! code snippet will be a great help...
    Edited by: kagaw3000 on Jul 27, 2008 8:22 PM

    final JTable table = new JTable(data, columnNames) {
    int lastRowChanged = -1;
    @Override
    public void tableChanged(TableModelEvent e) {
         super.tableChanged(e);
         lastRowChanged = e.getFirstRow();
         repaint();         
    @Override
    public Component prepareRenderer(TableCellRenderer renderer,
                   int rowIndex, int vColIndex) {
    Component c = super.prepareRenderer(renderer, rowIndex, vColIndex);
         if (rowIndex == lastRowChanged) {
              c.setBackground(Color.RED);
         } else { 
              c.setBackground(getBackground());
         return c;        
    ...........this code will changed background color when data was changed BUT if i changed another data in another row the previous backgound color(RED) will be erase. To make it more clearer, it will only change background color of a row only to one row NOT to multiple rows(that is being edited).

  • I would like the row color to alternate in pairs - for example, two rows of grey then two rows of white.  How do I achieve this format?

    I would like the row color to alternate in pairs - for example, two rows of grey then two rows of white.  How do I achieve this format?

    Hi OldRailroadMan,
    Here is one way. Start with a table with no fill (or white).
    Change the fill of the first two rows.
    Select cells in the first four rows.
    Drag the yellow Fill Handle down.
    For some reason this does not work if you select whole rows (by clicking on the row numbers at the left).
    When you are happy with the result, Menu > File > Save As Template.
    Regards,
    Ian.

  • How to set background color in row of JTable ?

    i am new in java please tell me about How to set background color in row of JTable ? please example code. Thnak you.

    Here is an example: http://www.javaworld.com/javaworld/javaqa/2001-09/03-qa-0928-jtable.html
    For more info on how to use tables read the swing tutorial: http://java.sun.com/docs/books/tutorial/uiswing/components/table.html
    ICE

  • How to change a color for a row in ALV grid display

    Hi,
       how to change a color for a row in ALV grid display based on a condition.Any sample code plz

    Hello Ramya,
    Did you check in [SCN|How to color a row of  alv grid]
    Thanks!

  • How to change the color of specific row in ALV tree

    Hi,
    I m using method set_table_for_first_display of a class CL_GUI_ALV_TREE.
    The req is to change the color of specific row. Now can anybody tell me how to change the color of ALV tree. As in ALV tree and in this method 'set_table_for_first_display', there is no parameter IS_Layout.
    Pls suggest...

    hi
    hope this code will help you.
    Reward if help.
    REPORT zsharad_test1.
    TABLES: ekko.
    TYPE-POOLS: slis. "ALV Declarations
    *Data Declaration
    TYPES: BEGIN OF t_ekko,
    ebeln TYPE ekpo-ebeln,
    ebelp TYPE ekpo-ebelp,
    statu TYPE ekpo-statu,
    aedat TYPE ekpo-aedat,
    matnr TYPE ekpo-matnr,
    menge TYPE ekpo-menge,
    meins TYPE ekpo-meins,
    netpr TYPE ekpo-netpr,
    peinh TYPE ekpo-peinh,
    line_color(4) TYPE c, "Used to store row color attributes
    END OF t_ekko.
    DATA: it_ekko TYPE STANDARD TABLE OF t_ekko INITIAL SIZE 0,
    wa_ekko TYPE t_ekko.
    *ALV data declarations
    DATA: fieldcatalog TYPE slis_t_fieldcat_alv WITH HEADER LINE,
    gd_tab_group TYPE slis_t_sp_group_alv,
    gd_layout TYPE slis_layout_alv,
    gd_repid LIKE sy-repid.
    *Start-of-selection.
    START-OF-SELECTION.
    PERFORM data_retrieval.
    PERFORM build_fieldcatalog.
    PERFORM build_layout.
    PERFORM display_alv_report.
    *& Form BUILD_FIELDCATALOG
    Build Fieldcatalog for ALV Report
    FORM build_fieldcatalog.
    There are a number of ways to create a fieldcat.
    For the purpose of this example i will build the fieldcatalog manualy
    by populating the internal table fields individually and then
    appending the rows. This method can be the most time consuming but can
    also allow you more control of the final product.
    Beware though, you need to ensure that all fields required are
    populated. When using some of functionality available via ALV, such as
    total. You may need to provide more information than if you were
    simply displaying the result
    I.e. Field type may be required in-order for
    the 'TOTAL' function to work.
    fieldcatalog-fieldname = 'EBELN'.
    fieldcatalog-seltext_m = 'Purchase Order'.
    fieldcatalog-col_pos = 0.
    fieldcatalog-outputlen = 10.
    fieldcatalog-emphasize = 'X'.
    fieldcatalog-key = 'X'.
    fieldcatalog-do_sum = 'X'.
    fieldcatalog-no_zero = 'X'.
    APPEND fieldcatalog TO fieldcatalog.
    CLEAR fieldcatalog.
    fieldcatalog-fieldname = 'EBELP'.
    fieldcatalog-seltext_m = 'PO Item'.
    fieldcatalog-col_pos = 1.
    APPEND fieldcatalog TO fieldcatalog.
    CLEAR fieldcatalog.
    fieldcatalog-fieldname = 'STATU'.
    fieldcatalog-seltext_m = 'Status'.
    fieldcatalog-col_pos = 2.
    APPEND fieldcatalog TO fieldcatalog.
    CLEAR fieldcatalog.
    fieldcatalog-fieldname = 'AEDAT'.
    fieldcatalog-seltext_m = 'Item change date'.
    fieldcatalog-col_pos = 3.
    APPEND fieldcatalog TO fieldcatalog.
    CLEAR fieldcatalog.
    fieldcatalog-fieldname = 'MATNR'.
    fieldcatalog-seltext_m = 'Material Number'.
    fieldcatalog-col_pos = 4.
    APPEND fieldcatalog TO fieldcatalog.
    CLEAR fieldcatalog.
    fieldcatalog-fieldname = 'MENGE'.
    fieldcatalog-seltext_m = 'PO quantity'.
    fieldcatalog-col_pos = 5.
    APPEND fieldcatalog TO fieldcatalog.
    CLEAR fieldcatalog.
    fieldcatalog-fieldname = 'MEINS'.
    fieldcatalog-seltext_m = 'Order Unit'.
    fieldcatalog-col_pos = 6.
    APPEND fieldcatalog TO fieldcatalog.
    CLEAR fieldcatalog.
    fieldcatalog-fieldname = 'NETPR'.
    fieldcatalog-seltext_m = 'Net Price'.
    fieldcatalog-col_pos = 7.
    fieldcatalog-outputlen = 15.
    fieldcatalog-datatype = 'CURR'.
    APPEND fieldcatalog TO fieldcatalog.
    CLEAR fieldcatalog.
    fieldcatalog-fieldname = 'PEINH'.
    fieldcatalog-seltext_m = 'Price Unit'.
    fieldcatalog-col_pos = 8.
    APPEND fieldcatalog TO fieldcatalog.
    CLEAR fieldcatalog.
    ENDFORM. " BUILD_FIELDCATALOG
    *& Form BUILD_LAYOUT
    Build layout for ALV grid report
    FORM build_layout.
    gd_layout-no_input = 'X'.
    gd_layout-colwidth_optimize = 'X'.
    gd_layout-totals_text = 'Totals'(201).
    Set layout field for row attributes(i.e. color)
    gd_layout-info_fieldname = 'LINE_COLOR'.
    gd_layout-totals_only = 'X'.
    gd_layout-f2code = 'DISP'. "Sets fcode for when double
    "click(press f2)
    gd_layout-zebra = 'X'.
    gd_layout-group_change_edit = 'X'.
    gd_layout-header_text = 'helllllo'.
    ENDFORM. " BUILD_LAYOUT
    *& Form DISPLAY_ALV_REPORT
    Display report using ALV grid
    FORM display_alv_report.
    gd_repid = sy-repid.
    CALL FUNCTION 'REUSE_ALV_LIST_DISPLAY'
    EXPORTING
    i_callback_program = gd_repid
    i_callback_top_of_page = 'TOP-OF-PAGE' "see FORM
    i_callback_user_command = 'USER_COMMAND'
    i_grid_title = outtext
    is_layout = gd_layout
    it_fieldcat = fieldcatalog[]
    it_special_groups = gd_tabgroup
    IT_EVENTS = GT_XEVENTS
    i_save = 'X'
    is_variant = z_template
    TABLES
    t_outtab = it_ekko
    EXCEPTIONS
    program_error = 1
    OTHERS = 2.
    IF sy-subrc <> 0.
    MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
    WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
    ENDIF.
    ENDFORM. " DISPLAY_ALV_REPORT
    *& Form DATA_RETRIEVAL
    Retrieve data form EKPO table and populate itab it_ekko
    FORM data_retrieval.
    DATA: ld_color(1) TYPE c.
    SELECT ebeln ebelp statu aedat matnr menge meins netpr peinh
    UP TO 10 ROWS
    FROM ekpo
    INTO TABLE it_ekko.
    *Populate field with color attributes
    LOOP AT it_ekko INTO wa_ekko.
    Populate color variable with colour properties
    Char 1 = C (This is a color property)
    Char 2 = 3 (Color codes: 1 - 7)
    Char 3 = Intensified on/off ( 1 or 0 )
    Char 4 = Inverse display on/off ( 1 or 0 )
    i.e. wa_ekko-line_color = 'C410'
    ld_color = ld_color + 1.
    Only 7 colours so need to reset color value
    IF ld_color = 8.
    ld_color = 1.
    ENDIF.
    CONCATENATE 'C' ld_color '10' INTO wa_ekko-line_color.
    wa_ekko-line_color = 'C410'.
    MODIFY it_ekko FROM wa_ekko.
    ENDLOOP.
    ENDFORM. " DATA_RETRIEVAL

  • How to get default color of a selected row in a JLIst

    I have a JList that I am changing the font color for based on a certian situation so I created my own MyCellRenderer to do this. However, when I select an item in the list the row is no longer highlighted. I used the isSelected method to determine if a row was selected and then change the background color of that row. However, I would like the color to be the default color that you get when you select a row in a default JList. I can't seem to figure out how to get that color. How do I obtain what that color is? I found an example where you can get the default color for the background of a button and use that color so I would guess it is something similar to that. My code is below so I hope someone can tell me how to get that color that I want.
    Thanks...Chris
    class MyCellRenderer extends JLabel implements ListCellRenderer {
         public MyCellRenderer() {
              setOpaque(true);
         public Component getListCellRendererComponent(
             JList list,
             Object value,
             int index,
             boolean isSelected,
             boolean cellHasFocus)
             int index1 = value.toString().indexOf("-");
               String errors = value.toString().substring(index1 + 1, index1 + 6).trim();
             int numErrors = Integer.parseInt(errors);
               if (numErrors > 0)
                      setForeground(Color.red);
                      setBackground(Color.white);          
             else
                  setBackground(Color.white);
                  setForeground(Color.black);
             if(isSelected)
                  //ColorUIResource col = (ColorUIResource)UIManager.getDefaults().get("JButton.background");
                  ColorUIResource col = (ColorUIResource)UIManager.getDefaults().get("Button.background");
                  setBackground(col);
             setText(value.toString());
             return this;
    }

    Swing related questions should be posted in the Swing forum.
    I would like the color to be the default color that you get when you select a row in a default JList. I can't seem to figure out how to get that colorlist.getSelectionBackground();

  • How to get the TableRow from TableView with given row Index.

    Hi ,
    I want to retrieve the TableRow object or Cells of that row of the TableView, for the given row index. How i can get that.
    Here is the below code what i am actually looking for
    TableView table = new TableView();
    table.getSelectionModel().selectedIndexProperty().addListener(new ChangeListener<Number>() {
         @Override
         public void changed(ObservableValue<? extends Number> paramObservableValue,Number prevRowIndex, Number currentRowIndex) {
              System.out.println(":::::::::>  Previous Row : "+prevRowIndex+" Current Row : "+currentRowIndex);
              if(prevRowIndex.intValue()>-1){
                   // TODO: Get the TableRow object of prevRowIndex or the cells in that row.
    });Thanks in advance !!

    Jonathan, Thanks for the info !
    Actually my requirement is ,
    1) I have an editable table with four columns. Where the first three colums are editable and the last column is a delete button to delete the record.
    2) My requirement is such that, whenever the user edits a cell, it is not comitted on focus out but the whole row(all cells) is comitted at a time when the user hits "enter". If the validation is not successfull, the textfields are styled with error class and focuses on it.
    So based on the key event on the textfield in the editable cell, i am fetching all the cells in the same row, with the below code.. and doing the save/update operation.
    textBox.setOnKeyReleased(new EventHandler<KeyEvent>() {
         @Override
         public void handle(KeyEvent t) {
              if (t.getCode() == KeyCode.ENTER) {
                          TableRowSkin<ContactPersonResponse> rowSkin = (TableRowSkin<ContactPersonResponse>) cell.getParent();
                    ObservableList<Node> cells = rowSkin.getChildren();
                    view.setCellAction(cells);
                          // The setCellAction(cells) will iterate through all the cells, validates the text field,
                          // if validation is success commits all the cells else styles the cells and focuses on the cell.
    });Till now everything is fine and working properly.
    Now I have new requirement that when the user edits a row (not yet comitted) and if he selects another row, the previous selected row should be automatically committed with validation.
    So my final action is to call the setCellAction(cells) by passing the cells of the previous selected row.
    table.getSelectionModel().selectedIndexProperty().addListener(new ChangeListener<Number>() {
         @Override
         public void changed(ObservableValue<? extends Number> paramObservableValue,Number prevRowIndex, Number currentRowIndex) {
              System.out.println(":::::::::>  Previous Row : "+prevRowIndex+" Current Row : "+currentRowIndex);
              if(prevRowIndex.intValue()>-1){
                   // TODO: Need to call the setCellAction method by passing the cells of previous selected row. (prevRowIndex)
                            // Here i am not getting how to get the cells of the previous row.          
    });In the selectedIndex listener , i am not getting how to get the cells/row from the index.
    Any solution or workaround for achieving this functionality is highly apprieciated .
    Thanks & Regards,
    Sai Pradeep Dandem.
    Edited by: Sai Pradeep Dandem on Jan 2, 2012 10:23 PM
    Edited by: Sai Pradeep Dandem on Jan 2, 2012 10:23 PM

  • How to fill a symbol with color

    How to fill a symbol with color?

    Good day!
    What do you mean by »symbol« in this case?
    Is this on a Layer of its own or is it part of a photograph?
    Could you please post a screenshot with the Layers Panel visible?
    Regards,
    Pfaffenbichler

  • JTree cell renderer: how to fill whole row?

    hi,
    i'm trying to make a tree cell renderer that renders at default height, but fills the horizontal width of the tree (e.g. with a JLabel with a custom background color). I'm working on the theory that in order to do this you need to change the preferred size of the component used to stamp the image at render time.
    The problem is that the preferred width then needs to be set to a value that depends on the context of the particular node (e.g. a deeply nested child node will be further to the right than the root node).
    I can't seem to find a method to say where the rendering starts though - does anyone know a way?
    (also if not then would setting the width to some astronimcal value break anything?)
    thanks,
    asjf

    Try this one, it will higlight the background and foreground colors of entire rows.
    Oscar
         class TableRenderer
              extends DefaultTableCellRenderer
              implements ListCellRenderer
              private boolean focused = true;
              private JLabel renderer;
              public TableRenderer()
                   super();
                   renderer = new JLabel();
                   renderer.setOpaque(true);
              public Component getListCellRendererComponent(
                   JList list,
                   Object value,
                   int index,
                   boolean isSelected,
                   boolean cellHasFocus)
                   return renderer;
              public Component getTableCellRendererComponent(
                   JTable table,
                   Object value,
                   boolean isSelected,
                   boolean hasFocus,
                   int row,
                   int column)
                   renderer =
                        (JLabel) super.getTableCellRendererComponent(
                             table,
                             value,
                             isSelected,
                             hasFocus,
                             row,
                             column);
                   /* Make the Labels border empty and indented */
                   setBorder(BorderFactory.createEmptyBorder(0, 5, 0, 0));
                   /* This is used to create alternate row colors */
                   Color bgColor = Color.white;
                   if (row % 2 == 0)
                        bgColor = new Color(237, 243, 254);
                   /* if the table has focus and the row is selected use these colors */
                   if (table.hasFocus() && table.getSelectedRow() == row)
                        table.setSelectionForeground(Color.WHITE);
                        table.setSelectionBackground(new Color(101, 137, 178));
                   /* if the table has not the focus but the row is selected use these colors */
                   else if (
                        table.hasFocus() == false && table.getSelectedRow() == row)
                        table.setSelectionBackground(new Color(196, 196, 194));
                   /* if not use the standard color */
                   else
                        renderer.setBackground(bgColor);
                        table.setSelectionForeground(SystemColor.textText);
                   if (value instanceof ColorData)
                        ColorData cvalue = (ColorData) value;
                        setForeground(cvalue.color);
                        setText(cvalue.data.toString());
                                /* Set the Labels value */
                   setText(String.valueOf(value));
                   return renderer;
         }

  • How to add rows in tableview using javascipt

    Hi
    I had tableview and button in my page.If i click on the button one new row should be appended to the existing tableview.
    so , how to add rows in tableview using javascipt which are editable?
    Regards,
    Pydi.

    Hi,
      Javascript is client scripting language, which is mainly used for validations at the client side.
      To add new row using a HTMLB tag ucannot use javascript. Instead pass "visibleRowCount" variable to a abap variable and add the variable on every button click.. that wil increase the visible row count.
    Also the size of the table view is the size of the itnernal table, so append a blank like to the internal table or insert it at the top.
    If you are not using HTMLB tags and using simple HTML tags u can always add a row using java script.
    Regards
    Imran.

Maybe you are looking for

  • How to access a  web service(.wsdl) from portal component.

    Hi , Is there any document/tutorial available on how to access a webservice from portal component ? I have found this linkhttps://www.sdn.sap.com/irj/servlet/prt/portal/prtroot/com.sap.km.cm.docs/library/ep/g-i/how to access a web service.htm... but

  • How to center or format embedded youtube video in Dreamweaver CS4?

    I'm pretty new at using Dreamweaver, but I created a website that I would like to embed a youtube video in. I've got the embedding part down-- copying code-- but it doesn't format. I have a couple of APDivs at the top of the page, and I'd like the vi

  • Making Posting date field Mandatory in DP91 screen

    Hi All, Is it possible to make the posting date field mandatory in the DP91 screen. Currently if the posting date is not specified, system will always consider the current date as posting date and picks the appropriate actual line items.   Is its pos

  • Tv show episode will not go onto my Ipod Nano 7th generation.

    I already Unchecked Download HD when availible and downloaded the Sd version but it still won't work! All of the other episodes worked fine except this one! I went back and checked to see and make sure I unchecked the box and it keeps checking itself

  • Significance of the field "REVERSAL INDICATOR"

    hI gURUS, I am trying to load data from R/3 source system to BW. I have a key field where data is positive but when it is getting transferred to BW it is getting zero. I checked in PSA, data is there but I have a field "REVERSAL INDICATOR" whch shows