17 Replies Latest reply: Aug 17, 2012 3:06 PM by Naga Devisetty RSS

How to select a single column in a table?

TJ Amorado
Currently Being Moderated

I have a table with data, i would like to only highlight a single column. does anyone know how to do it?

 

example data:

ID
Name
Position
1JohnManager
2PeterSales
3MarkCook

 

I would like to highlight only the ID column and copy the data.

 

Thanks!

  • Re: How to select a single column in a table?
    prodyot sen
    Currently Being Moderated

    Check this thread - http://scn.sap.com/thread/1701486

     

    Cheers,

    Sen

  • Re: How to select a single column in a table?
    Amol Gupta
    Currently Being Moderated

    Hi TJ,

    You can lead select a row but not a column.

    The only work around seems to color a column on some condition.

     

    Regards,

    -Amol Gupta

    • Re: How to select a single column in a table?
      TJ Amorado
      Currently Being Moderated

      Hi Amol,

       

      So do you mean that it's not possible to create a single column selection like we can do on excel? like this one:

       

      column selection excel.png

       

      Thanks!

      • Re: How to select a single column in a table?
        Amol Gupta
        Currently Being Moderated

        Hi TJ,

        Bad news is NO you can not do a Column selection in Web Dynpro Java directly but the good news is that you can export your Web dynpo table to an excel and then do the usual Excel tricks on it.

         

        Reusable WebDynpro Component for Export to Excel from Table UI Element. (Generic Method).

        http://www.sdn.sap.com/irj/scn/go/portal/prtroot/docs/library/uuid/d01854fd-1579-2c10-63ad-dd62edca2381?QuickLink=index&overridelayout=true

         

        SCN Thread

        http://scn.sap.com/thread/1176783

         

        Regards,

        -Amol

        • Re: How to select a single column in a table?
          TJ Amorado
          Currently Being Moderated

          Thanks Amol!

          • Re: How to select a single column in a table?
            Robin van het Hof
            Currently Being Moderated

            This is not quite true; you can bind the column property 'colSelectionState' to a context attribute.

             

            Then you can define an event handler to the table event 'onColSelect'.

             

            Bind the 'col' property of the event handler to an Action parameter, and you should be able to retrieve the context attribute values for the corresponding column.

            • Re: How to select a single column in a table?
              Amol Gupta
              Currently Being Moderated

              Hi TJ,

              One can acess/read context in any way (including rowwise, columnwise, alternate rows, alternate column, diagonal, corners etc) using programming but selecting/lead selecting a column like excel as illustrated in the screenshot above will not be possible directly on WebDynpro Java screen.

               

              Some properties may be dependent on version. Which version of NWDS are you using ?

              As in NWDS 7.01 there is no column property colSelectionState, but there is an onAction property(at bottom). Some properties might differ across versions 7.0, 7.1, 7.2, 7.3 and respective Enhacement Packs (EHPs).

               

              column.jpg

               

              Also, depends on what excatly you want do to with the values in the column -

              1). Do you just want to highlight a column ?

              Ans. use coloring

               

              2). You want to all Excel like operation on a column?

              Ans. Download WebDynpro Table to Excel

               

              3). You just want to have read values of a column ?

              Ans. You can read your context in any way you like based on some logic programmatically. you can list, contatenate or show up some specific values of a table based on some logic (row, column, diagonal) in some other UI element and use Copy+Paste to copy the values.

               

              Possibilities are endless. The answer will depend on your scenario or business requirement. Web Dynpro Java empowers you to manipulate data in many ways programmatically.

               

              Thanks and Regards,

              -Amol Gupta

              • Re: How to select a single column in a table?
                TJ Amorado
                Currently Being Moderated

                Hi Amol,

                 

                I'm using NWDS 7.01. Well basically what i'm looking is to be able to copy the whole value of a single column. is single cell selection will be the answer? Thanks!

                • Re: How to select a single column in a table?
                  Amol Gupta
                  Currently Being Moderated

                  Hi TJ,

                       I made a sample application just for your problem.

                   

                  I made the following context for a table -

                  Context.jpg

                   

                  I made the following Table in the view Layout -

                  table.jpg

                  I wrote the following code for wdDoInit() to populate the table-

                  //@@begin javadoc:wdDoInit()

                  /** Hook method called to initialize controller. */ 

                  //@@end 

                  public void wdDoInit()

                  {

                       //@@begin wdDoInit()

                      IPrivateMainView.ITableNodeElement ele = wdContext.createTableNodeElement();

                       ele.setField1("R1F1");

                       ele.setField2("R1F2");

                       ele.setField3("R1F3");   
                       wdContext.nodeTableNode().addElement(ele);

                   

                       ele = wdContext.createTableNodeElement();

                       ele.setField1("R2F1");

                       ele.setField2("R2F2");

                       ele.setField3("R2F3");   

                       wdContext.nodeTableNode().addElement(ele);

                       //@@end

                    }

                   

                  As shown below i selected the Column in the outline and created an Action for OnAction Event

                  *Pls click on the image to see an enlarged image.

                  ColAction.jpg

                  *Pls click on the image to see an enlarged image.

                   

                  I wrote the following code for the action -

                  //@@begin javadoc:onActionConacatenateAndListField1Values(ServerEvent)

                  /** Declared validating event handler. */

                  //@@end

                  public void onActionConacatenateAndListField1Values(com.sap.tc.webdynpro.progmodel.api.IWDCustomEvent wdEvent )

                  {

                       //@@begin onActionConacatenateAndListField1Values(ServerEvent)

                     String str = "";

                      for(int i=0; i<wdContext.nodeTableNode().size(); i++)

                      {

                                str = str + wdContext.nodeTableNode().getTableNodeElementAt(i).getField1() +", ";

                      }

                      wdComponentAPI.getMessageManager().reportSuccess(str);
                       //@@end

                  }

                   

                  You will see the following output (a comma separated list) on clicking at the top  of the column and you can see that you can also copy it-

                  table2.jpg

                   

                  You may also consider showing this list of values which i have shown in a message in an Input Field UI element or equivalent or export the table to Excel if in case the table has too many values.

                   

                  I hope this solves your problem. 

                   

                  Regards,

                  -Amol Gupta

            • Re: How to select a single column in a table?
              TJ Amorado
              Currently Being Moderated

              Robin,

               

              When you use a higher version like CE. is it possible that to happen?

               

              Thanks!

  • Re: How to select a single column in a table?
    Nagavara Prasad B
    Currently Being Moderated

    Hi TJ,

     

    Please fallow the steps in order to get the specified column data in table

    -get the table node and from that get the attribute corresponding to that column

    - this thing can be done by using the node iteration

    -now take that attribute value into some other attribute.

  • Re: How to select a single column in a table?
    Jana Neujahr
    Currently Being Moderated

    Hi TJ,

     

    After reading all entries to your question there still are some unclear aspects to your problem.

    Please try to answer the following questions thoroughly:

     

    How do you want the "copy" action to be?

    Do you want to...

    - copy content into the PC-clipboard? (as copying text by CTRL+C)

    -  have an action in Web Dynpro that provides "copied" content?

     

    What exactly do you want to copy?

    - the values as shown in the table?

    - the whole attributes/variables?

    - the column as such?

     

    Where you you want to enter the copied content afterwards?

    - into another Table in Web Dynpro?

    - into some extern Text-document?

    - into a WD-Context?

     

    Unfortunately I myself am not firm in WD-tables, but maybe your answers to these questions provide better understanding for the helpers here.

     

    Regards

    Jana

    • Re: How to select a single column in a table?
      TJ Amorado
      Currently Being Moderated

      How do you want the "copy" action to be?

      Do you want to...

      - copy content into the PC-clipboard? (as copying text by CTRL+C)

      -  have an action in Web Dynpro that provides "copied" content?

       

      I want copy using the CTRL+C

       

      What exactly do you want to copy?

      - the values as shown in the table?

      - the whole attributes/variables?

      - the column as such?

       

      the values with the column format

       

      Where you you want to enter the copied content afterwards?

      - into another Table in Web Dynpro?

      - into some extern Text-document?

      - into a WD-Context?

       

      Well, according to our client they paste it in an excel file.

       

      Thanks!

      • Re: How to select a single column in a table?
        Vishweshwara P K M
        Currently Being Moderated

        Hi TJ,

         

        If the requirement is just to allow the users to copy the data and paste it in an excel, provide an "Export to Excel" option (a button or Link to Action UI) and on click of this, using JXL.jar API generate the excel out of the data in the table. This way the user will be getting the entire table data into an excel.

         

        Also you can allow the user to select a column of the table (by means of check box added to each column as fixed top cell), which has to be exported to excel.

         

        Regards,

        Vishweshwara P.K.M.

        • Re: How to select a single column in a table?
          TJ Amorado
          Currently Being Moderated

          Hi Vishweshwara,

           

          The client doesn't want the export to excel function, I guess they think that it's slow.

          Thanks for the suggestion!

          • Re: How to select a single column in a table?
            Naga Devisetty
            Currently Being Moderated

            Hi TJ,

             

            If copy is the only purpose of this whole discussion.. its been almost answered by Amol's last reposnce in this thread... you might just make the below change ... that's all:

            str = str + wdContext.nodeTableNode().getTableNodeElementAt(i).getField1() +"\n ";

            Or when the Table Column has an event called onAction()... why dont you populate/display an excel below the table with the filled values of the selected column - then it becomes easy to copy.

            EXCEL - I'm here to use OfficeControl UI element or use any other UI element that can allow you to select the values on the clicked-column for COPY-PASTE.

             

            -Thanks,

            MS