How  to resize the column header according to row data

Hi,
How can i resize the column header according to row date .. means if data is small header should be small and vice versa ,...
Any help is appreciated .. Snippet will be more helpful .
Thanks,
Shekhar

Oxley (binkley) blogged about this: http://binkley.blogspot.com/2006/01/getting-jtable-columns-widths-to-fit.html
Christian Ullenboom | tutego

Similar Messages

  • How to display the column header in two rows?

    Hi Experts,
    I am using ALV_LIST_DISPLAY i neeed to display the column header in two rows.. How can i do that?
    Ex: purchase order i  need to display "purchase" in one row and "order" in second row.
    Thanks in advance,
    Sarath.j

    REPORT zpwtest .
    TYPE-POOLS slis .
    DATA : layout TYPE slis_layout_alv .
    CONSTANTS : c_len TYPE i VALUE 20 .
    TYPES : BEGIN OF ty_t100          ,
              sprsl TYPE t100-sprsl   ,
              arbgb TYPE t100-arbgb   ,
              msgnr TYPE t100-msgnr   ,
              text  TYPE t100-text    ,
              fline TYPE t100-text    ,
            END OF ty_t100            .
    TYPES : BEGIN OF ty_wrd   ,
             text TYPE char20 ,
            END OF ty_wrd     .
    DATA : it_t100     TYPE TABLE OF ty_t100 ,
           it_sentence TYPE TABLE OF ty_wrd  ,
           wa_t100     TYPE ty_t100          ,
           wa_word     TYPE ty_wrd           ,
           v_repid     TYPE syst-repid       ,
           v_tabix     TYPE syst-tabix       .
    DATA : it_fld TYPE slis_t_fieldcat_alv ,
           it_evt TYPE slis_t_event        ,
           wa_fld TYPE slis_fieldcat_alv   ,
           wa_evt TYPE slis_alv_event      .
    INITIALIZATION .
      v_repid = sy-repid .
    START-OF-SELECTION .
    * Get data
      SELECT *
        INTO TABLE it_t100
        FROM t100
       WHERE sprsl = 'EN'
         AND arbgb = '00' .
      LOOP AT it_t100 INTO wa_t100 .
        v_tabix = sy-tabix .
        CLEAR : it_sentence .
        CALL FUNCTION 'RKD_WORD_WRAP'
             EXPORTING
                  textline  = wa_t100-text
                  outputlen = c_len
             TABLES
                  out_lines = it_sentence.
        IF NOT it_sentence IS INITIAL .
          READ TABLE it_sentence INTO wa_word INDEX 1 .
          wa_t100-fline = wa_word-text .
          MODIFY it_t100 FROM wa_t100 INDEX v_tabix .
        ENDIF.
      ENDLOOP.
    * Prepare fieldcatelog
      CLEAR wa_fld .
      wa_fld-fieldname = 'SPRSL' .
      wa_fld-ref_tabname = 'T100' .
      wa_fld-ref_fieldname = 'SPRSL' .
      APPEND wa_fld TO it_fld .
      CLEAR wa_fld .
      wa_fld-fieldname = 'ARBGB' .
      wa_fld-ref_tabname = 'T100' .
      wa_fld-ref_fieldname = 'ARBGB' .
      APPEND wa_fld TO it_fld .
      CLEAR wa_fld .
      wa_fld-fieldname = 'MSGNR' .
      wa_fld-ref_tabname = 'T100' .
      wa_fld-ref_fieldname = 'MSGNR' .
      APPEND wa_fld TO it_fld .
      CLEAR wa_fld .
      wa_fld-fieldname = 'FLINE' .
      wa_fld-inttype      = 'CHAR' .
      wa_fld-outputlen = 20 .
      wa_fld-intlen    = 20.
      wa_fld-seltext_l = 'Text' .
      wa_fld-ddictxt = 'L' .
      APPEND wa_fld TO it_fld .
    * Get event.. we will handle BOFORE and AFTER line output
      CALL FUNCTION 'REUSE_ALV_EVENTS_GET'
           IMPORTING
                et_events = it_evt.
      READ TABLE it_evt INTO wa_evt
      WITH KEY name = slis_ev_after_line_output .
      wa_evt-form = slis_ev_after_line_output .
      MODIFY it_evt FROM wa_evt INDEX sy-tabix .
      READ TABLE it_evt INTO wa_evt
      WITH KEY name = slis_ev_top_of_page .
      wa_evt-form = slis_ev_top_of_page .
      MODIFY it_evt FROM wa_evt INDEX sy-tabix .
      layout-no_colhead = 'X' .
      CALL FUNCTION 'REUSE_ALV_LIST_DISPLAY'
           EXPORTING
                i_callback_program = v_repid
                it_fieldcat        = it_fld
                is_layout          = layout
                it_events          = it_evt
           TABLES
                t_outtab           = it_t100.
    *       FORM top_of_page                                              *
    FORM top_of_page .
        uline .
        WRITE: / sy-vline     ,
               10 sy-vline    ,
               11 'line1'     ,
               31 sy-vline    ,
               37 sy-vline    ,
               58 sy-vline    .
        WRITE: / sy-vline     ,
               10 sy-vline    ,
               11 'line2'     ,
               31 sy-vline    ,
               37 sy-vline    ,
               58 sy-vline    .
        WRITE: / sy-vline     ,
               10 sy-vline    ,
               11 'line3'     ,
               31 sy-vline    ,
               37 sy-vline    ,
               58 sy-vline    .
    ENDFORM.
    *       FORM AFTER_LINE_OUTPUT                                        *
    FORM after_line_output   USING rs_lineinfo TYPE slis_lineinfo .
      CLEAR : it_sentence ,
              wa_t100     .
      READ TABLE it_t100 INTO wa_t100 INDEX rs_lineinfo-tabindex .
      CHECK sy-subrc = 0 .
      CALL FUNCTION 'RKD_WORD_WRAP'
           EXPORTING
                textline  = wa_t100-text
                outputlen = c_len
           TABLES
                out_lines = it_sentence.
      DESCRIBE TABLE it_sentence LINES v_tabix .
      CHECK v_tabix > 1 .
      LOOP AT it_sentence INTO wa_word FROM 2 .
        WRITE: / sy-vline     ,
               10 sy-vline    ,
               31 sy-vline    ,
               37 sy-vline    ,
               38 wa_word-text ,
               58 sy-vline .
      ENDLOOP.
    ENDFORM .

  • Change the column header according to the filter value ?

    Hello Experts,
    I have a requirement in which the customer wants to change the column header of the Sales Volume Key Figure to change according to the filter selected for the Calender Year / Month in the Free characteristics.
    I could display the header as 'Sales Volume for OCT 2000' as this is the value restricted intially in the free characteristics for Calender Year / Month.
    Any suggestion is appreciated.
    Thanks,

    Ioan Thanks for the reply.
    Probably my previous explanation of the problem was a little incomplete. Let me give a better description.
    The situation is something like this.
    I have a requirement in which the customer wants the column header to reflect the 'keep filter value' restriction that he does dynamically in the query report.
    i.e:
    -- usually the kf column header shows 'sales volume'
    -- column header with text variable of the Calender year / month variable -- 'sales volume for 2000 oct'
    -- but when the report is run, if the user wants to go and change the filter:   calender year / month > rt clk > keep filer value > select Jan 2003.
      The kf column header still shows 'Sales Volume 2000 Oct'
    How to make the column header change to 'sales volume for Jan  2003' ?
    Any suggestions greatly appreciated.
    Thanks,

  • How to fix the column header width in BEx or WAD

    hi there!
    how to fix the column header width in BEx or WAD. because, depends on the column data, the column size varies. i want to fix the size so that i can maintain the consistency through out the report.
    thanks!
    Vam.

    Dear Vam,
    you can easily do that with css, search the source code of the executed web template for the td tag which is around your coloumn header, remember the style sheet class name it is ´displayed as class= in the td tag.
    Now you can add this code the beginning of your web template:
    </style>
    This will only work in Web.
    Regards
    Marcus

  • How to resize the columns of a table?

    Hi there!
    I want to resize the column of a JTable(constructed via AbstractTableModel) to
    fit the exact width of the word in the header?
    Can anyone tell me how to do this thing?
    Regards,

    import java.awt.*;
    import javax.swing.table.*;
    public class ColumnResizeDemo extends javax.swing.JFrame {
        public ColumnResizeDemo() {
            initComponents();
            TableColumn column = null;
            for (int i = 0; i < jTable1.getColumnModel().getColumnCount(); i++) {
                column = jTable1.getColumnModel().getColumn(i);
                String hv = column.getHeaderValue().toString();
                JTableHeader th = jTable1.getTableHeader();
                FontMetrics fm = th.getFontMetrics(th.getFont());
                column.setPreferredWidth(fm.stringWidth(hv)+5);
        private void initComponents() {
            jLabel1 = new javax.swing.JLabel();
            jScrollPane1 = new javax.swing.JScrollPane();
            jTable1 = new javax.swing.JTable();
            setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
            setTitle("Column Resize Demo");
            jLabel1.setText("Sets column width to fit exactly the corresponding header value");
            getContentPane().add(jLabel1, java.awt.BorderLayout.NORTH);
            jTable1.setModel(new javax.swing.table.DefaultTableModel(
                    new Object [][] {
                        {null, null, null, null},
                        {null, null, null, null},
                        {null, null, null, null},
                        {null, null, null, null}
                    new String [] {
                "Title 1", "Title 0002", "Title 0000003", "Title 00000000000004"
            jTable1.setAutoResizeMode(javax.swing.JTable.AUTO_RESIZE_OFF);
            jScrollPane1.setViewportView(jTable1);
            getContentPane().add(jScrollPane1, java.awt.BorderLayout.CENTER);
            pack();
        public static void main(String args[]) {
            new ColumnResizeDemo().setVisible(true);
        private javax.swing.JLabel jLabel1;
        private javax.swing.JScrollPane jScrollPane1;
        private javax.swing.JTable jTable1;
    }

  • How to change the column heading as the column changes

    dear memebrs,
    Take an example fo the table EMP. I need to create a report whose parameters are the table column names. so depending on the parameter(which is the column name) the report o/p changes.
    so i am dynamically selecting the table column names and getting the o/p. The problem is when the column changes the heading of it in the report o/p is not changing.
    we have to use format trigger for this, but i am not sure what code should we write in the format trigger of the boiler plate text of the column heading , such that it changes in accordance with the input which is nothing but column name.
    for ex: If i choose EMPNO as the parameter then my column heading should become Employee Number and so on.......
    your comments are welcomed
    regards
    sandeep

    you can use a formula column of datatype character and of any width needed instead of a boilerplate text for the heading name.
    In the formula column you can write code like below
    IF :P_COLUMN_NAME = EMPNO THEN
    return('Employee Number');
    ELSIF :P_COLUMN_NAME = SAL THEN
    return('Salary');
    END IF;
    where P_COLUMN_NAME the name of the column selected dynamically(i.e. the parameter).

  • How to repeat the column header on each page of the report?

    Can any of you please suggest me on how to repeat the column titles on a table if the table extends over several pages:
    I tried the below action present in Re: How to make the column title needs to be on each page? It worked fine for the pdf format whereas its not working for rtf format output.
    Can anybody help on this?

    I guess this has been taken as bug,
    may be some patch got released for it..iam not sure..

  • How to change the column header name dynamically based on sysdate

    Post Author: senthi_gokul
    CA Forum: WebIntelligence Reporting
    Dear All,
            i have designed some reports. i would like to change the column header dynamically based on sysdate. up to 24 months. can u help me, which add month function using the universe. i dont know if-then-else function is having the universe tool or not?

    Post Author: prasingh
    CA Forum: WebIntelligence Reporting
    Are you saying you are not able to create an object by value (select: statement) as sysdate and put it onto the headers of your report? You can use the add_months() function on the object to add the numbers of months you wish.
    Please let me knnow for more.. You can get in touch with me on [email protected] for quick reply. 

  • How to resize the columns in the report

    Hi
    I want to resize the columns in my report to make them smaller so that they don't overlap, but after resizing the columns still overlap so that some columns headings are under the other ones.
    Thanks

    You can do it either by, going to the property palette of the column and then change the horizontal elasticity to 'Variable', this way it will shrink or enlarge the size automatically. Or, you can do in manually in the layout model, click the column then click the edge of the field and drag it to make it longer or shorter.
    -Marilyn

  • How to change the column header in XsltListView webpart

    I have a XsltListView webpart. By default it displays the column name in the header. How do I change the header and give a friendly name? I am able to change the header, if I click on header and position the cursor at the right spot and change. But sometimes
    it does not work. Is there any property which I can set in order to change the header? Thanks in advance.
    ss

    Hi ss,
    Do you use SharePoint 2007 or 2010? And the XsltListView Web part only available in SharePoint 2010.
    If you are using SharePoint 2010, to customize the header for each column, please try the following step.
    Open list view in advanced mode in SharePoint Designer.
    Select a header you need to modify > Click Customize XSLT under Design tab on the ribbon > Click “Customize Item”.
    Then we can see <xsl:value-of select="$fieldtitle"/> has selected in Code view > Replace it with the text you want to display on the header.
    For example, I want to display the string “customized header” in the header, then replace
    <xsl:value-of select="$fieldtitle"/>
    With
    Customized header
    Save the page and test.
    Thanks & Regards,
    Emir Liu
    TechNet Subscriber Support in forum
    If you have any feedback on our support, please click here.
    Emir Liu
    TechNet Community Support

  • How to ignore the column header in GUI_UPLOAD

    Hi,
    I am trying to use GUI_UPLOAD to upload data from text file into a table. However there is no parameter to ignore the column headers in this function. how can i set to ignore the column headers in this function?

    Check the function module documentation and also refer to the parameter: HEADER_LENGTH
    Length of Header for Binary Data
    Description
    Specifies the length of the header information. You must only set this parameter if the file type is 'BIN'. The default value '00' means that there is no header in the file.
    Default
    '00'

  • How to fix the column header

    Try to display something like this:<br><br>
    HA HB <br>
    A1 B1<br>
    A2 B2<br>
    <br>
    So I use:
    <div class="Show2Rows"><br>
    <table><br>
    <tr><br>
    <th>HA</th><br>
    <th>HB</th><br>
    </tr><br>
    <tr><br>
    <td><input ... value="A1" ></td><br>
    <td><input ... value="B1" ></td><br>
    </tr><br>
    <br>
    </table><br>
    </div><br>
    <br>
    The rule is: allow it to display ONLY two rows in the window. When more rows are added, a vertical scroll bar will be enabled. --And, yes, it works just as expected.
    The problem is that when more rows are added, when I scroll the bar downward, of course the rows will move up. When this happens, the Column Headers (HA and HB) will disappear. Obviously I need to fix the Column Headers.
    So question is: How can I fix the headers while still be able to scroll the data rows up and down?
    Thanks

    Dear Vam,
    you can easily do that with css, search the source code of the executed web template for the td tag which is around your coloumn header, remember the style sheet class name it is ´displayed as class= in the td tag.
    Now you can add this code the beginning of your web template:
    </style>
    This will only work in Web.
    Regards
    Marcus

  • How to resize the column of alv depending upon the textbox settings in i.e

    Hi,
    I am using ALV component in one of my WD applications. ALV has a column date. If i resize the textbox from the internet explorer setting ( page->textsize in i.e.7) to anything greater than medium, the content of the columns is hidden.
    For example, if the date is displayed as 25/07/2010, after resizing it appears as 25/07...
    i have tried using column property of the alv : set_width and set_resizable, but it doesnt give the desired output.
    Please give ur suggestions.
    Regards,
    Varuna

    Hi,
    Would increasing the width of ALV itself help?
    using IF_SALV_WD_TABLE_SETTINGS~SET_WIDTH().
    Regards,
    Aditya.

  • How to change the column value upto 68000 rows

    Hi,
    I want to change the column value.
    I have table called RefDoc
    Select distinct r.int_ref from refdoc r where r.int_ref like '\\dxb%'
    Int_Re__f
    \\dxb\Sample\BFE B777\2008\PO2025225.tif
    \\dxb\Sample\RO\SFR\26-01-2009j\RO2022098.pdf
    \\dxb\Sample\RO\SFR\26-01-2009j\RO2040831.pdf
    \\dxb\Sample\BFE B777\2008\PO2025253.tif
    \\dxb\Sample\RO\UM INV\26-01-2009\RO2018358.pdf
    up to 68000 rows
    I want to change to \\AUH instead of \\dxb.
    I want the table like
    Int_Re__f
    \\AUH\Sample\BFE B777\2008\PO2025225.tif
    \\AUH\Sample\RO\SFR\26-01-2009j\RO2022098.pdf
    \\AUH\Sample\RO\SFR\26-01-2009j\RO2040831.pdf
    \\AUH\Sample\BFE B777\2008\PO2025253.tif
    \\AUH\Sample\RO\UM INV\26-01-2009\RO2018358.pdf
    Thanks
    Nihar

    user REPLACE function and change it
    UPDATE refdoc
       SET int_ref = REPLACE(int_ref, '\\dxb\', '\\AUH\')
    WHERE int_ref like '\\dxb\%'

  • How to Hide the Column Heading of BEx Query Output

    Hi Experts,
    I Designed  BEx Query for BO Xcelsius, at the time of showing Bex Report in  Xcelsius
    it is displaying the like
                 Calday           01.01.2010      02.01.2010.............
    Plant     keyfigure
    P1        Plan                 10                         9
    P1        Actual               8                          5
    P2        Plan                 12                          6
    P2        Actual               9                          4
    we need display without  keyfigure - row like follwing ( when we run report on analyzer it showing without  keyfigure - row,but problem is when we Run in web)
    Plant     Calday           01.01.2010      02.01.2010.............
    P1        Plan                 10                         9
    P1        Actual               8                          5
    P2        Plan                 12                          6
    P2        Actual               9                          4
    Or with out Header Row
    P1        Plan                 10                         9
    P1        Actual               8                          5
    P2        Plan                 12                          6
    P2        Actual               9                          4
    How can we achive this
    In Bex query design
    Rows - Plant, Key figures - Actual,Plan
    Column - 0Calday
    Thanks,
    Chandra

    We do not have any direct setting in BEx to do it. You can write a VB macro code in BEx to achieve this.

Maybe you are looking for

  • Export button for crystalreportviewer control not showing ddl entries for..

    we have a .net web application that was created using asp.net 1.1.  It displays crystal reports using the crystalreportviewer control. Once the report is displayed, the user clicks on the export button and it looks just fine. so everything is ok when

  • LR5 Library mode slow to show adjustments

    I'm having a serious problem with the thumbnails in Library/Grid mode taking anywhere from 5-10 seconds to "pop in" the adjustments I've made in develop and/or via the quick develop tab. I need to quickly see if large batches of images are similar in

  • Custom Master Text Tables

    Hi, I'm creating a customer master report and having problem determining the text tables of some fields: a.) Sales Region b.) Sales Office c.) Customer Group d.) Delivery Priority e.) Shipping Conditions f.) Delivering Plant g.) Partial delivery per

  • Supress details in subreport based on date ranges in main report

    I am using Crystal XI R2 and am working with Human Resources Data. The main report is grouped on and generates a list of temporary teaching positions like this: Smith, John      FTE_____Start Date_______End Date       .3 ______09/01/2007______10/20/2

  • Date Format in Autosave Vault

    I have just noticed that the date format used in the names of Autosaved files in the Autosave Vault Folder are in the US format which I find confusing and risks error. How can I change this to the European format of dd/mm/yy? (I have searched the man