How to set column widths in tables for selected table only, not globally throughout document?

I've been utilizing the below script (thank you so much Ramkumar. P!) to set column widths throughout a sizable InDesign book with tables on every page and it is truly a time saver. At this point in time, I have three versions of it because there are different column widths throughout the book. Is it possible to augment the script to run only on a selected text frame (containing a table)? If so, would someone be kind enough to share the augmented script with me? I've been trying to figure out this seemingly simple change through trial and error with no success as yet. I realize this is a totally newbie request and I'm entirely at the mercy of the kindness of the Javascript gods that contribute within this forum. Seeing that in a different post related to this script, one such guru responded to a request as simple as "Where do I put the scripts in InDesign" gave me enough courage to ask for some help! Thank you in advance to anyone willing to provide a solution.
  var myDoc = app.activeDocument;
     var myWidths = [100, 100, 150, 150];
     for(var T=0; T < myDoc.textFrames.length; T++){
         for(var i=0; i < myDoc.textFrames[T].tables.length; i++){
             for(var j=0; j < myWidths.length; j++){
                 myDoc.textFrames[T].tables[i].columns[j].width = myWidths[j];
     alert("Table width updated successfully...");

Hello all
I have the same problem in that I'm not a scripting person, but was able to get the above script working without problem, and it does set irregular table column widths perfectly, so thanks to Ramkumar. P for that.
BUT, it changes the column width for ALL tables in the document, whereas I would like to just target the selected table.
Any ideas as to how I might amend this script to achieve this?
Thx, Christian

Similar Messages

  • How to set column width in alvgrid

    hi
    how to set column width in alvgrid.
    thanks.

    Hi,
    Check this,
    REPORT  ztest.
    DATA: BEGIN OF i_scarr_tab OCCURS 0.
            INCLUDE STRUCTURE  scarr.
    DATA: END OF i_scarr_tab.
    DATA: i_scarr LIKE TABLE OF i_scarr_tab WITH HEADER LINE,
          w_scarr LIKE LINE OF i_scarr_tab.
    DATA: o_grid      TYPE REF TO cl_gui_alv_grid,
          o_container TYPE REF TO cl_gui_custom_container.
    DATA: lt_fcat     TYPE lvc_t_fcat,
          ls_layo     TYPE lvc_s_layo,
          ls_sort     TYPE lvc_s_sort,
          lt_sort     TYPE lvc_t_sort,
          ls_fieldcat TYPE slis_t_fieldcat_alv WITH HEADER LINE.
    START-OF-SELECTION.
      CALL SCREEN 9000.
    *&      Module  status_9000  OUTPUT
          text
    MODULE status_9000 OUTPUT.
      SET PF-STATUS '9000'.
      SET TITLEBAR '9000'.
    ENDMODULE.                 " status_9000  OUTPUT
    *&      Module  user_command_9000  INPUT
          text
    MODULE user_command_9000 INPUT.
      CASE sy-ucomm .
        WHEN 'BACK' OR 'EXIT'.
          SET SCREEN 0.
          LEAVE SCREEN.
      ENDCASE.
    ENDMODULE.                 " user_command_9000  INPUT
    *&      Module  init_9000  OUTPUT
          text
    MODULE init_9000 OUTPUT.
      IF o_container IS INITIAL.
        SELECT * FROM scarr INTO CORRESPONDING FIELDS OF TABLE
           i_scarr UP TO 100 ROWS.
        IF cl_gui_alv_grid=>offline( ) IS INITIAL.
    Create a custom container control for ALV Control
          CREATE OBJECT o_container
              EXPORTING
                  container_name = 'CONTROL'.
    Create a ALV Control
          CREATE OBJECT o_grid
              EXPORTING i_parent = o_container.
          PERFORM build_field_catalgue.
          ls_layo-sel_mode = 'A'.
          CALL METHOD o_grid->set_table_for_first_display
            EXPORTING
              i_save          = 'A'
              i_default       = 'X'
              is_layout       = ls_layo
            CHANGING
              it_outtab       = i_scarr[]
              it_fieldcatalog = lt_fcat
              it_sort         = lt_sort[].
        ENDIF.
      ENDIF.
    ENDMODULE.                 " init_9000  OUTPUT
    *&      Form  build_field_catalgue
          text
    -->  p1        text
    <--  p2        text
    FORM build_field_catalgue .
      DATA: ls_fcat TYPE lvc_s_fcat.
      CALL FUNCTION 'REUSE_ALV_FIELDCATALOG_MERGE'
        EXPORTING
          i_program_name         = sy-cprog
          i_internal_tabname     = 'I_SCARR_TAB'
          i_structure_name       = 'SCARR'
         i_client_never_display = 'X'
        CHANGING
          ct_fieldcat            = ls_fieldcat[]
        EXCEPTIONS
          inconsistent_interface = 1
          program_error          = 2
          OTHERS                 = 3.
      IF sy-subrc <> 0.
        MESSAGE 'FCAT Error' TYPE 'I'.
        EXIT.
      ENDIF.
      LOOP AT  ls_fieldcat.
        CLEAR ls_fcat.
        ls_fcat-fieldname = ls_fieldcat-fieldname.     "Fieldname
        ls_fcat-ref_table = ls_fieldcat-tabname.       "DDIC ref struct
        ls_fcat-inttype   = ls_fieldcat-inttype.       "Data type
        ls_fcat-outputlen = ls_fieldcat-outputlen.     "Column width
        ls_fcat-coltext   = ls_fieldcat-seltext_m.     "Column Header
        ls_fcat-seltext   = ls_fieldcat-seltext_m.     "Column Desc
        ls_fcat-ref_field = ls_fieldcat-ref_fieldname. "Reference field
        ls_fcat-ref_table = ls_fieldcat-ref_tabname.   "Reference table
        CASE  ls_fieldcat-fieldname.
          WHEN 'LUGGWEIGHT' OR 'FORCURAM'.
            ls_fcat-edit      = 'X'.
            ls_fcat-do_sum    = 'X'.
          WHEN 'URL'.
            ls_fcat-no_out = 'X'.
          WHEN OTHERS.
            ls_fcat-edit      = ' '.
            ls_fcat-do_sum    = ' '.
        ENDCASE.
        APPEND ls_fcat TO lt_fcat.
      ENDLOOP.
    ENDFORM.                    " build_field_catalgue
    check the programs bcalv_grid*.
    check this link for more detailed example.
    http://www.supinfo-projects.com/fr/2005/alv_display_fr/2/
    Regards
    Sruthi

  • Please help me :How to set the width and height for my View page "test.htm"

    Hi,
        I have controller class. When i call the view[test.htm]from this controller class ,i am getting the view with output tableview..it is fine.
    My requirement:
                 the output view window is showing full browser window. I want the view output like showModeldialog. I want to set the width and height for the output view window. How is possible?
                 or
    i want to call the test.view in the window.showModelDialog..
    Please help me .. Urgent requirement.

    Yes you can set the width & Height of the view as follows..
    <div style="width:580px; height:750px; margin-top:15px; overflow:auto;">
    <htmb:form......>
    </htmlb:form>
    </div>
    <i>*Reward each useful answer</i>
    Raja T

  • How to set column width for Label in Form region?

    In the form region, the label value is a lengthy text, and it does not wrap. How do I make it wrap to a fixed column width?
    Under Home>Application Builder>Application>Page>Edit Page Item,
    i have set "HTML Table Cell Attributes" to width="300", but it still does not wrap. and pushes the field to the right end of the page.
    I am quite sure there are better ways of doing this.

    thanks Simakas for the reply.
    I had set the label template to "Optional" and that was forcing a "nowrap". After unsetting the template, I used your suggestion and it works like a charm. Thanks.

  • How to set column width in GridPane in FXML?

    I would like to set width, for ex, of column 4 in GridPane.
    I can do like this:
    <columnConstraints>
                <ColumnConstraints prefWidth="100"/>
                <ColumnConstraints prefWidth="200" />
                <ColumnConstraints prefWidth="200" />
                <ColumnConstraints prefWidth="200" />
    </columnConstraints>If i have 10 columns should i add 10 column constraints? (i need to set only width of 4th column)
    How can i do it easier?

    >
    Hi, Can someone please help on how to set the columnwidth in csv file using javacode.
    I used FileWriter class to upload data into the csv file but csv file is taking default width while showing content. Is there a way to set the fixed column width or set width dinamically based on value?
    >
    The fields in CSV (Comma-Separated-Value) files are separated by commas; they do not have a fixed width.

  • How to set column width based on header width?

    I have a column that will only hold 1 character. This is good, but I want the Column width to match the column header.
    For example,
    Currently I get:
    select * from table;
    I NAME
    1 ROBERT
    The problem is, I want the Column header spelled out (in this case it's just ID)
    ID NAME
    1 ROBERT
    Better Yet,
    if i did:
    select ID "ID NUMBER", NAME "FIRST NAME" from table;
    I'd like to see:
    ID NUMBER FIRST NAME
    1 ROBERT
    (Centering the ID within the Column width would be good too, but that is "gravy")
    Any thoughts? I've been trying:
    COLUMN ID FORMAT A10 (which obviously didn't work!)
    Thanks,
    KSL.
    Edited by: leonhardtk on Aug 23, 2010 11:55 AM

    If you use tags it'll be easier to see what formatting effects you're talking about.
    Does <a href="http://download.oracle.com/docs/cd/E11882_01/server.112/e10823/ch_six.htm"><tt>col id head "ID Number" format a9</tt></a> do what you want?
    Edited by: William Robertson on Aug 23, 2010 6:50 PM                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                           

  • How to adjust Column width using SHD0 for FB60

    Hi,
    How can adjust ( i have to reduce the length) Assignment filed in the FB60 transaction using SHD0.
    Please help in this regard.
    Regards,
    Kishore

    HI,
    I think you can adjust the column width and save it as Screen Variant in the SHD0.
    When you create a screen variant for the MIRO, adjust your column width and position than save it the variant. Once you save and activate the variant, it will appear in the Layout dropdown box on MIRO.
    OR
    Please check in spro with ur functional consultant to explore if the field can be made not mandatory..
    menu path:
    AR and AP -> Customer Accounts -> Line Items -> Display line items -> display line items without ALV

  • How to set column width in OBIEE

    hi ,
    I want to set the coumn width in table, my version is obiee 10.
    any one know how adjust the width of column?
    thanks.

    Use column properties->Additional Formatting Options
    and set width 10px or as per your req.
    Pls mark correct/helpful if helps

  • How do I use my original iphone for videos & apps only, not as phone

    I want to use my original iphone as a video and app player(not a phone) for my daughter, using my library of purchases on my account. I have an iphone 3G and my original iphone is not being used. How do I do this?

    After an iPhone is no longer activated, you can't install a firmware update or restore the iPhone with iTunes (which re-installs the firmware) since activation is required in order to do so.
    I'm not aware of a way to roll a restore back.
    If you have the SIM card that was used when this iPhone was activated, you can try inserting the SIM card and do another restore. Someone here reported that it is possible to install a firmware update or restore an iPhone with iTunes that is no longer activated as long as the SIM card that was used with the iPhone when activated is inserted.
    Message was edited by: Allan Sampson

  • How do I set column widths in read/write rules?

    Hello structure experts,
    I am reading a set of DITA files into a specific FM template format, and there is one detail I cannot get to work properly. It should be possible to define column widths in a table, even if the DITA file does not include that information. But the Structure Application Developer Reference does not give the information on which string to pass to the column widths fm property. Does anyone out there have experience in doing this ?
    Thanks
    Jang

    Got it !!!
    Turned out to be simple, but the info was more or less hidden in the Dev Ref Guide: I had already put the "fm property column widths is value " line in but did not know the syntax for the values. Turns out you need to delimit the values by spaces, not commas. The parser does not give ANY useful information about this, just mentions 'syntax error near somewhere' or completely ignores the values you specify.
    This is how the rule for my DITA properties element now works out:
    element "properties" {
      is fm table element;
      fm property columns value is "3";
      fm property column widths value is "5cm 5cm 6cm";
    It works. I earn 10 points for answering my own question. :-)
    Ciao
    Jang

  • How can I set column width in JTable?

    How can I set column width in JTable?

    Also, read the JTable API before posting questions. You will find a link to the Swing tutorial on "How to Use Tables", which contains an example of doing exactly this.

  • How to set the width for a selectManyShuttle component

    Hi,
    I'm using selectManyShuttle component from Oracle ADF Core and some of the items in the showing list are long, therefore the width of selectManyShuttle expands the page. How to set the width property for selectManyShuttle component? After that does selectManyShuttle provide horizontal scrollbar as well?
    Thanks in advance,
    lapi
    Message was edited by:
    [email protected]
    Message was edited by:
    [email protected]

    Solution here:
    Re: ADF Faces Scrollable Panel or Scroll Bar inside a component
    Regards
    Grant

  • How to set the WIDTH and ALIGN of h:column in h:dataTable ??

    How to set the WIDTH and ALIGN of <h:column> in <h:dataTable>??
    Thanks a lot!

    Hi,thanks to your reply.
    Now I find a more convenient appraoch to set column's width and align respectively:
    <h:dataTable ...>
    <h:column>
    <f:facet name='header'>
    </f:facet>
    <h:outputText style="width:80px; text-align: right;" value='#{row.fieldA}'/>
    </h:column>
    <h:column>
    <f:facet name='header'>
    </f:facet>
    <h:outputText style="width:120px; text-align: left;" value='#{row.fieldB}'/>
    </h:column>
    </h:dataTable>
    It works fine.
    ^-^

  • HELP Friends!!! How to set the width of columns of JTABLE?

    Hi!
    How to set the width of a particular column in JTable?
    I tried using headerRenderers and though I'm able to set the color and font of the header (using getTableCellRendererComponent method)I can't change the size.
    Pls some one help me..it's very urgent.
    Thanks in advance.
    Regards,
    Naval

    JTable.getColumnModel().getColumn(i).setWidth(width). There are also setPreferredWidth, setMaxWidth and setMinWidth methods.

  • How to set columns for Zip Codes?

    I am new to iMac and in my first week using trial version of Numbers. I work in sales and we do lots of mailings using merging of data and addresses for post cards, labels, etc.
    I cannot see how to set columns to a zip code setting. All zips entered beginning with a 0 drop the front 0. I tried calling the column as Text, but it did not help. I can type a ' in from of the 0 and it works, but this takes an insane amount of time and will not work for us.
    How do you deal with Zip Codes? Are there labeling options for mailing built into Numbers? I really want to dump all MS products but will have to drop mac and return buy Office if this is not correctable.
    Thank you,
    Brownie

    Hello
    Setting the column format to text do the trick on my french version too.
    With AppleWorks, I was accustomed to use a zeroSlashed so it remained in my zip codes when I moved codes here and there.
    Yvan KOENIG (from FRANCE jeudi 13 septembre 2007 17:44:38)

Maybe you are looking for

  • Is there a better way to stop a Method than Thread.stop()?

    First my basic problem. In one of my programs I am using constraint solver. I call the constraint solver with a set of constraints and it returns a Map with a satisfying assignment. In most cases this works in acceptable time ( less than 1 second). B

  • Substitution variable in BR Graphical Interface

    Hi, we have a business rule using a prompt that we would like to change to a subtitution variable. But we can't just enter "&AnCour" (for current year). I didn't found any place where I could select my substitution variables (I can select prompts and

  • Join two ODS into one cube!

    Hello Experts - I need to join fields of 2 ODS into one cube. I know the common field. We are in BI 7.0. Can someone guide me through the steps? I know there are two transformation rules. And I have created them. How do I link them so that I have one

  • Is there any way I can use bi beans without the patches

    I am a Chinese student,I am doing some research on OLAP. I'm in the initial stages of evaluating BI Beans for my research. We have previously not used Oracle in house. In attempting to use BI Beans, the first thing you must do is install the latest p

  • Where download K60 Manager SW?

    I've downloaded the the file for the K60 drivers (i.e. A140509_enu_xp.exe).  However where is the download for the K60 Officejet SW for managing scanning, faxing,  etc.  The SW would help with faxing, it would show the printer panel, etc.  Thanks