How to enforce always sorting on a column in a TableView?

Hello,
I have a requirement to always sort on a column in a TableView.
So basically, I need a TableColumn's SortType go from Ascending to Descending and back to Ascedning when user clicks on a column header repeatedly.
I guess that means making sure a TableView's SortOrder list is not empty. Am I right?
I tried to listen to SortOrder list changes like below:
tableView.getSortOrder().addListener(new ListChangeListener<TableColumn<String, ?>>() {
     @Override
     public void onChanged(final javafx.collections.ListChangeListener.Change<? extends TableColumn<String, ?>> arg0) {
if (tableView.getSortOrder().size() > 0) {
               // fine. nothing to do
          else {
// add the removed column back
Is this the right approach?
I'm not sure how to use arg0 and add the removed column back.
Can people with experience in this area provide some sample code?
Thanks.

The solution I came up with was to save the last column added to the SortOrder list to a map.
Whenever the SortOrder list becomes empty, I add the last saved column back to the SortOrder list.
That seems work.
Edited by: 925616 on Aug 3, 2012 3:33 PM
Edited by: 925616 on Aug 3, 2012 3:33 PM

Similar Messages

  • How to increase the width of the column in Tableview

    Hi ALL,
    How to increase the width of the column in tableview?I have name column where big name is displaying in rows.Does any one have any idea how to increase the width of the column dynamically in tableview.Please respond its little urgent.
    Thanks in advance

    Hi Peter,
    Here is my Dynpage
    package com.ust.jcatotable;     
    import java.awt.Event;
    import javax.resource.cci.MappedRecord;
    import javax.resource.cci.RecordFactory;
    import com.sapportals.connector.connection.IConnection;
    import com.sapportals.connector.execution.functions.IInteraction;
    import com.sapportals.connector.execution.functions.IInteractionSpec;
    import com.sapportals.connector.execution.structures.IRecordSet;
    import com.sapportals.htmlb.DropdownListBox;
    import com.sapportals.htmlb.event.TableNavigationEvent;
    import com.sapportals.htmlb.page.DynPage;
    import com.sapportals.htmlb.page.PageException;
    import com.sapportals.portal.htmlb.page.JSPDynPage;
    import com.sapportals.portal.htmlb.page.PageProcessorComponent;
    import com.sapportals.portal.ivs.cg.ConnectionProperties;
    import com.sapportals.portal.ivs.cg.IConnectorGatewayService;
    import com.sapportals.portal.ivs.cg.IConnectorService;
    import com.sapportals.portal.prt.component.IPortalComponentContext;
    import com.sapportals.portal.prt.component.IPortalComponentProfile;
    import com.sapportals.portal.prt.component.IPortalComponentRequest;
    import com.sapportals.portal.prt.component.IPortalComponentResponse;
    import com.sapportals.portal.prt.runtime.PortalRuntime;
    public class Display extends PageProcessorComponent {
      public DynPage getPage(){
         return new DisplayDynPage();
    public static class DisplayDynPage extends JSPDynPage{
         private Object formatFlag;
         public static IConnection connection ;
         private IPortalComponentRequest request;
         private IPortalComponentContext context;
         private IPortalComponentProfile profile;
         private IPortalComponentResponse  response;
         private int visibleRow=1;
         TableBean myBean;
         public void doInitialization(){
                   response = (IPortalComponentResponse) this.getResponse();
                   request = (IPortalComponentRequest) this.getRequest();
                    context = request.getComponentContext();
                    profile = context.getProfile();
                    IPortalComponentProfile profile = context.getProfile();
                    Object o = context.getValue("myBean");
                    if(o==null || !(o instanceof TableBean)){
                       myBean = new TableBean();
                       setBeanFromProfile(profile, myBean);
                       context.putValue("myBean",myBean);
                     }else {
                       setBeanFromProfile(profile, myBean);
                        myBean = (TableBean) o;
                    this.getData();
         public void myOnNavigate(Event event) throws PageException{
              TableNavigationEvent tne = (TableNavigationEvent) event;
              this.visibleRow = tne.getFirstVisibleRowAfter();
              if(myBean!=null)
              myBean.setVisibleRow(new Integer(this.visibleRow).toString());

  • How to disable sorting for some columns in a ALV GRID?

    Hi i have requirement where I have to disable sorting for some columns in a ALV GRID. i am using REUSE_ALV_GRID_DISPLAY function module.
    Can anybody help me. how to acieve this? Any code snippets will really be appreciated.

    Hi,
    I have tried this but not completely successful. I think this can be done using the OOPS method.
      DATA: it_event_exit TYPE  slis_t_event_exit.
      DATA: w_exit TYPE slis_event_exit.
      w_exit-ucomm = '&ODN'.
      w_exit-before = 'X'.
      CLEAR w_exit-after.
      APPEND w_exit TO it_event_exit.
      w_exit-ucomm = '&OUP'.
      w_exit-before = 'X'.
      CLEAR w_exit-after.
      APPEND w_exit TO it_event_exit.
      CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
        EXPORTING
          i_callback_program          = w_repid
          i_callback_top_of_page      = 'ALV_TOP_OF_PAGE'
          i_callback_html_top_of_page = 'ALV_HTML_TOP_OF_PAGE'
          i_callback_user_command     = 'USER_COMMAND'  <- User command form
          is_layout                   = wm_layout
          it_fieldcat                 = wt_fieldcat
          it_events                   = i_events
          it_event_exit               = it_event_exit    <- Need to fill
          it_sort                     = wt_sort
          i_default                   = 'X'
    Now you can capture this events in the user command
    FORM user_command  USING r_ucomm LIKE sy-ucomm
                             rs_selfield TYPE slis_selfield.
      IF r_ucomm = '&OUP' and rs_selfield-SEL_TAB_FIELD = 'Your field name'.
      ENDIF.
    ENDFORM.                    "user_command
    In this form you will get the function code in 'r_ucomm' and the field selected for sorting in 'rs_selfield-SEL_TAB_FIELD'. But reseting 'r_ucomm' will not work.
    May be somebody else can give some help on this.
    But this will work if you follow the oop method.
    Please see this document for more info.
    http://www.sdn.sap.com/irj/servlet/prt/portal/prtroot/com.sap.km.cm.docs/library/webas/abap/an easy reference for alv grid control.pdf
    Thanks
    Vinod

  • How do I sort data in columns using Pages

    How do I sort data in columns (alphabetically) using Pages?

    If you are referring to text or numbers in a column (not table), then get the free Service plug-in WordService, from Devon Technologies. Put it in the
    /Users/yourlogin/Library/Services folder location.
    Select your data to be sorted. From the Pages menu > Services > Sort Ascending will do the trick. This will work with Pages ’09 and Pages v5.2 or later, as well as Apple Mail, TextEdit, etc.
    The WordService files include a PDF (Read Me) that describes the services included with the package.
    The Service items will only appear in the Services submenu when you have selected your data prior to sort. If these WordService items do not appear in the Services menu as they should per the preceding sentence, then you will need to enable them.
    System Preferences > Keyboard > Shortcuts > Services. Scroll through the right hand list of services until you encounter Sort Ascending and ensure that it is selected.
    If you were referring to sorting a column of data in a table:
    Pages ’09
    Select all cells containing your unordered data. In the Table Inspector, under Edit Rows & Columns, choose Sort Ascending.
    Pages v5.2
    Select cells as before. In the Table heading (A, B, C, etc.) when you roll over the letter, a down-arrow appears. Click, and choose Sort Ascending from the drop down menu.

  • How to sort on Multiple columns in WebI report

    Hi
             I am working in BO XI R2. I have a report containing two columns in a section. Section is on Fiscal Year- Fiscal year includes calendar year 2010 and 2011.
    data for fiscal year 2010 is from october onwards.
    The two columns in the section are
    column 1- calendar  Year
    column 2- calendar Month
    I want to display results as follows
    2010 oct
    2010 nov
    2010 dec
    2011 jan
    2011 feb and so on.
    I first sorted calendar year column so that it shows
    2010
    2011
    but when i try to sort calendar month, for 2010 I am able to display oct, nov, dec in a ascending order but for 2011 the months are displayed randomly. Business user wants to see them in ascending order from Jan to June.
    Please let me know how to get this functionality in the report.
    Thanks in advance.

    Hello Gurus,
    I have same issue with me I am working on XI3.1 and I want to apply Sort on multiple columns on Single block.
    So as you can see the "Org Name" is decending Order and " Emails Sent" total is 63 and   "BCB" have 18 total.
    How would I apply sorting based on email sent from high number to low number. Please help.
    Thank you.
    Adil
    Org Name
    Org Tax ID
    Org ID
    Email
    Emails Sent
    Undelivered Emails
    Well Shot
    11111111
    22222222
    [email protected]
    32
    0
    11111111
    22222222
    [email protected]
    12
    0
    11111111
    22222222
    [email protected]
    10
    0
    11111111
    22222222
    [email protected]
    9
    0
    Well Shot
    Subtotal:
    63
    0
    Org Name
    Org Tax ID
    Org ID
    Email
    Emails Sent
    Undelivered Emails
    Well Play
    444444444
    33333333
    [email protected]
    1
    0
    WellPoint KY Test Org - Central
    Subtotal:
    1
    0
    Org Name
    Org Tax ID
    Org ID
    Email
    Emails Sent
    Undelivered Emails
    BCB
    55555555
    99999999
    [email protected]
    8
    0
    55555555
    99999999
    [email protected]
    8
    0
    55555555
    99999999
    [email protected]
    2
    0
    BCB
    Subtotal:
    18
    0
    Org Name
    Org Tax ID
    Org ID
    Email
    Emails Sent
    Undelivered Emails
    Ghazi, Foundation
    77777777
    8888888
    [email protected]
    1
    0
    77777777
    8888888
    [email protected]
    1
    0
    77777777
    8888888
    [email protected]
    1
    0
    77777777
    8888888
    [email protected]
    1
    0
    77777777
    8888888
    [email protected]
    1
    0
    Ghazi, Foundation
    Subtotal:
    5
    0
    Availity Orgnaization Name
    Org Tax ID
    Org ID
    Email
    Number of Emails Sent
    Undelivered Emails
    Ghazi, Foundations
    66666666
    1234567893
    [email protected]
    1
    0
    66666666
    1234567893
    [email protected]
    1
    0
    Ghazi,  Foundations
    Subtotal:
    2
    0
    Totals:
    89
    0

  • Hi how to apply Chronological sort for a month column?

    Hi All,
    I am struck with how to apply Chronological sort for a month column that contains values like January, February, March, April, May, June.... December. If we apply normal sorting then we can arrange the column values either in ascending order or descending order. But i want the column values to be in this format like jan, feb, mar,apr....dec. Is it possible???
    If this is possible then pls tell me the way in a step wise manner for my better understanding..
    Thanks in Advance
    Thenmozhi

    Hi Deva,
    I tried with the below formula :
    CASE WHEN
    "Order Booked Date Calendar"."Full Month Name (Order Booked)"='January' THEN 1 WHEN
    "Order Booked Date Calendar"."Full Month Name (Order Booked)"='February' THEN 2 WHEN
    "Order Booked Date Calendar"."Full Month Name (Order Booked)"='March' THEN 3 WHEN
    "Order Booked Date Calendar"."Full Month Name (Order Booked)"='April' THEN 4 WHEN
    "Order Booked Date Calendar"."Full Month Name (Order Booked)"='May' THEN 5 WHEN
    "Order Booked Date Calendar"."Full Month Name (Order Booked)"='June' THEN 6 WHEN
    "Order Booked Date Calendar"."Full Month Name (Order Booked)"='July' THEN 7 WHEN
    "Order Booked Date Calendar"."Full Month Name (Order Booked)"='August' THEN 8 WHEN
    "Order Booked Date Calendar"."Full Month Name (Order Booked)"='September' THEN 9 WHEN
    "Order Booked Date Calendar"."Full Month Name (Order Booked)"='October' THEN 10 WHEN
    "Order Booked Date Calendar"."Full Month Name (Order Booked)"='November' THEN 11 WHEN
    "Order Booked Date Calendar"."Full Month Name (Order Booked)"='December' THEN 12 ELSE '' END
    But it is showing the error like this:
    Error Details
    Error Codes: OPR4ONWY:U9IM8TAC:OI2DL65P
    State: HY000. Code: 10058. [NQODBC] [SQL_STATE: HY000] [nQSError: 10058] A general error has occurred. [nQSError: 43113] Message returned from OBIS. [nQSError: 43119] Query Failed: [nQSError: 17001] Oracle Error code: 604, message: ORA-00604: error occurred at recursive SQL level 1 ORA-06502: PL/SQL: numeric or value error: character string buffer too small ORA-06512: at line 8 ORA-00932: inconsistent datatypes: expected NUMBER got CHAR at OCI call OCIStmtExecute. [nQSError: 17010] SQL statement preparation failed. (HY000)
    What it is problem? Please help me...
    Thanks

  • How to get ALV Display with First column alone in sort

    How to get ALV Display with First column alone in sort

    HI,
    You can build Internal Table and send this to the parameter "IT_SORT".
    eg:
    "the sorting Internal Table structure is as whown below.
    DATA:  t_sort_info type slis_t_sortinfo_alv.
    "Build the Sort Internal Table
      t_sort_info-fieldname = 'CARRID'.
      t_sort_info-subtot = 'X'.
      append t_sort_info.
      t_sort_info-fieldname = 'FLDATE'.
      t_sort_info-subtot = 'X'.
      append t_sort_info.
    Then pass this "IT_SORT_INFO" table to the Function module "Reuse_alv_*". (Note send the body of the Internal table only like "<b>IT_SORT = IT_SORT_INFO[]</b>".
    Here i am making ALV output sorted on CARRID & FLDATE.
    You can specify only the First Column name for sorting.
    Regards,
    Manju
    Message was edited by:
            MANJUNATHA KS

  • We used to be able to sort by multiple columns/rows at once by right clicking on the header and choosing show more options-how do we do that in the new Numbers?

    We used to be able to sort by multiple columns/rows at once by right clicking on the header and choosing show more options-how do we do that in the new Numbers?  It doesn't appear anywhere.  Do I now have to sort massive tables by each column one at a time now?  Also there used to be an easier way to merge/unmerge cells without me having to go to the table menu each time.  Am I missing something?

    Multiple column sort is a missing feature in the new version.  Hopefully soon to return. You can do a multicolumn sort by sorting one at a time in reverse order of importance.
    For merging and unmerging cells, I select the cells and right click to bring up the contextual menu. Merge and unmerge are on the menu.  You could also create keyboard shortcuts for Merge Cells and Unmerge Cells in the Table menu.

  • How to display the sorting arrows in the table column header

    Hi
    I am doing a sorting for some columns from the click of the table column headers, In Developer studio, we are able to view the up and down arrows, I need that also to be made visible at run time, so that the user knows that there exists sorting based on that particular column. Is there any other way of doing it ? I cant place more than one control on the header or wrap the text to two lines..also. please clarify. thanks

    I assume you are using NW 04.
    The table column header contains a IWDCaption element which may display an icon and a text. See property IWDCaption.imageSource.
    The table tutorial might also be helpful.
    Armin

  • How can I sort alphabetically three columns?

    Hi to everybody!
    I've got some problems sorting alphabetically three columns. If I try to sort one column it changes also the others. I want three independent columns and each of them must be sorted out alphabetically.
    In Excel it's so easy: I just have to select the column and push the button "sort the column alphabetically". Why is that so difficult in numbers?
    Check it out: http://yfrog.com/j6screenshot01tj

    l,
    What is the nature of the content in the three columns? If the content is just data, and not calculations or the input to calculations, you can easily accomplish a single column sort in Numbers.
    I see from your screen shot that you are still in the Excel mindset. You have a large table with more rows and columns empty than occupied. To work most effectively in Numbers we usually use only as many rows and columns as necessary, and if we have data that is of another set and not related, we begin a new table.
    So, if your data meets the requirements of the first paragraph and you have trimmed away the excess rows and columns we can do the following: Click once on the label of the column you wish to independently sort. Then click again on this label and drag it up and away from the table to a blank area of the canvas. Perform the sort on the separated column. Then grab the sorted column in the same way as before and move it over the original table, watching the borders between columns highlight as you move over them. The double line between columns identifies the insertion point. When you have your sorted column in the right place, drop it back into the original table.
    Jerry

  • How to enforce index

    Hi Guys,
    How to enforce index ?
    Say for example,
    select max(dt) from emp
    emp table has an index called 'id1'.
    I want to enforce this index for the above query. How ?
    Inputs are welcome !

    Your index on ID is worthless for this query.
    You would have to add an index on your DT column. Even then, the index will only be used if you have a NOT NULL constraint on the column (or add "and dt is not null" to your query):
    SQL> explain plan for
      2  select min(dt), max(dt) from emp;
    Explained.
    | Id  | Operation            |  Name       | Rows  | Bytes | Cost  |
    |   0 | SELECT STATEMENT     |             |     1 |     8 |   194 |
    |   1 |  SORT AGGREGATE      |             |     1 |     8 |       |
    |   2 |   TABLE ACCESS FULL  | EMP         | 91000 |   710K|   194 |
    SQL> alter table emp modify (dt not null);
    Table altered.
    SQL> explain plan for
      2  select min(dt), max(dt) from emp;
    Explained.
    | Id  | Operation             |  Name       | Rows  | Bytes | Cost  |
    |   0 | SELECT STATEMENT      |             |     1 |     8 |    39 |
    |   1 |  SORT AGGREGATE       |             |     1 |     8 |       |
    |   2 |   INDEX FAST FULL SCAN| EMP_DT      | 91000 |   710K|    39 |
    ---------------------------------------------------------------------Still, even without an index a full table scan of 91000 rows takes < 1 second even on my laptop. How are you getting 21 seconds?

  • How to display the sort value in the selection screen in the report title

    Dear All,
    How to display the sort value in the selection screen in the report title? I have selected a value in the selection screen for sorting , but i need that values by which i have sorted with in the report title. Can you please throw some light on this!!
    Good day,
    Thanks and regards
    Arun S

    Hi Arun,
    Try this.
    1, Set one dynamic parameter,
    2, Drag and drop that parameter into  your report title.
    3, Pass the value(sort value) dynamically from your application,
    4, Cheers..
    Other wise Try with Dataset, create a dataset and fill thev alue into that.. Then  set the data source from CR designer. and darg and drop that data column into the report.
    Hope this will work,
    Regards,
    Salah
    Edited by: salahudheen muhammed on Mar 25, 2009 11:13 AM

  • How to enforce index in oracle query

    Hi all
    how to enforce index in oracle query
    Regards

    Use INDEX hint to force Optimizer to use the specfied index.
    You really need to investigate why Optimizer doesn't choose the index. Remember, INDEX SCAN are not always GOOD.
    Jaffar

  • HT2470 Why does this not explain how to change the sort order?

    Why does this (i.e. support at Apple.com) not explain how to change the sort order? I can "arrange" by Date Modified for example but it won't let me switch to use most recent dates first. Also, what is Apple-speak for arrange versus sort anyway? It seems I used to be able to click on a column heading in finder and get a drop down arrow allowing me to change the sort sequence.

    Arrange roughly translates to "group the items in the folder." Sort is how each group is ordered. If you have arrange set to none, you can sort by anything. However, there is no way in the Arrange/Sort menu to choose the direction. The only way to do that is in the List View, and you must have Arrangement set to None.
    I've submitted an Enhancement Request to allow choosing sort direction from the Arrange/Sort menu, but I haven't ever gotten a response, which is good and bad. Good because they will often respond that they have considered it and don't plan on implementing. Bad in that they've haven't implemented it.

  • Sorting feature for columns in time approval screen - MSS

    Hi ,
    In the portal for MSS , while on the 'Approve Time Sheet Data' , how can we provide sorting for the different columns ? As of now , the sort is only available on the Employee column .We want to provide the same on the Att/Abs type column too.Is this achievable through personalization in the portal or handled through some code ? Kindly suggest. Thanks in advance.

    CATS_APPR_PERSP
    Here you define the approval views
    In the first case it can determined by period, in case
    you dont use period then  collective approval criteria.
    can be used for grouping
    Example period
    Period Type
    Specifies the period for which the recorded data
    is to be grouped in one line of the collective approval.
    Please check the IMG for cross application components and Approve working time

Maybe you are looking for

  • Short Dump while execuition of DTP.

    Hi, I got short dump while  execuiting the DTP. Error messages shows as below: 1.The database returned a value containing an error 2.An exception with the type CX_SY_OPEN_SQL_DB occurred, but was neither handled locally, nor declared in a RAISING cla

  • Taking too much time to connect SAP B1

    Dear All, My Addon is running successfully in one server. While the same Addon is taking too much time to connect ( near oCompany.Connect). Can anyone give me any idea regarding this.. Thanks in advance.. Regards Sanjay

  • My iPad crashes whenever I try to open the Newsstand or iBooks store

    Hi all. Whenever I launch the Newsstand or iBooks stores, either from the applications or from a download link online, the app crashes immediately. The App Store and iTunes work fine. Would appreciate any help with this!

  • Export bookmarks to Excel or Open Office Calc spreadsheet

    How can I export bookmarks to a spreadsheet like Calc or Excel, where they can be searched, sorted, de-duplicated, etc. ?

  • Transferring windows media file to iTunes.

    I recently published a vidio on windows movie maker, I want to put it on iTunes so I can sync it to my ithouch. However, I tried to import it to iTunes, and nothing happened. Plz help.