Table Sorting: How is firstVisibleRow being affected?

Dears,
I'm confused at table sorting using Tablesorter.java.
When sorting, how does Tablesorter affect the firstVisibleRow of the table?
In the "[Working with tables|https://www.sdn.sap.com/irj/sdn/go/portal/prtroot/docs/library/uuid/90ac0015-d1c5-2a10-d788-aed89990811d]" sample SDN provided, when press "sorting asending" or "sort descending", the table's first visible row changes automatically.
I didn't understand why firstVisibleRow changed to be so. And I don't know how the firstVisibleRow will change to be.
I checked the code of Tablesorter, and I also tried to debug into it, but didn't find any track.
Any word is appreciated. Thanks in advance.
Edited by: gangtee gangtee on May 2, 2008 4:59 PM

Attached is Tablesorter.java
package com.sap.tc.webdynpro.tests.utils;
import java.text.Collator;
import java.util.ArrayList;
import java.util.Collection;
import java.util.Comparator;
import java.util.HashMap;
import java.util.Iterator;
import java.util.Map;
import java.util.StringTokenizer;
import com.sap.tc.webdynpro.clientserver.uielib.standard.api.IWDAbstractDropDownByIndex;
import com.sap.tc.webdynpro.clientserver.uielib.standard.api.IWDAbstractDropDownByKey;
import com.sap.tc.webdynpro.clientserver.uielib.standard.api.IWDAbstractInputField;
import com.sap.tc.webdynpro.clientserver.uielib.standard.api.IWDAbstractTableColumn;
import com.sap.tc.webdynpro.clientserver.uielib.standard.api.IWDCaption;
import com.sap.tc.webdynpro.clientserver.uielib.standard.api.IWDCheckBox;
import com.sap.tc.webdynpro.clientserver.uielib.standard.api.IWDLink;
import com.sap.tc.webdynpro.clientserver.uielib.standard.api.IWDProgressIndicator;
import com.sap.tc.webdynpro.clientserver.uielib.standard.api.IWDRadioButton;
import com.sap.tc.webdynpro.clientserver.uielib.standard.api.IWDTable;
import com.sap.tc.webdynpro.clientserver.uielib.standard.api.IWDTableCellEditor;
import com.sap.tc.webdynpro.clientserver.uielib.standard.api.IWDTableColumn;
import com.sap.tc.webdynpro.clientserver.uielib.standard.api.IWDTableColumnGroup;
import com.sap.tc.webdynpro.clientserver.uielib.standard.api.IWDTextEdit;
import com.sap.tc.webdynpro.clientserver.uielib.standard.api.IWDTextView;
import com.sap.tc.webdynpro.clientserver.uielib.standard.api.WDTableColumnSortDirection;
import com.sap.tc.webdynpro.progmodel.api.IWDAction;
import com.sap.tc.webdynpro.progmodel.api.IWDCustomEvent;
import com.sap.tc.webdynpro.progmodel.api.IWDNode;
import com.sap.tc.webdynpro.progmodel.api.IWDNodeElement;
import com.sap.tc.webdynpro.progmodel.api.IWDViewElement;
import com.sap.tc.webdynpro.services.sal.localization.api.WDResourceHandler;
* Helper class that makes a Web Dynpro table UI element sortable (column-wise).
public final class TableSorter {
      * @param table
      * @param sortAction
      * @param comparators
     public TableSorter(IWDTable table, IWDAction sortAction, Map comparators) {
          init(table, sortAction, comparators, null);
     public TableSorter(IWDTable table, IWDAction sortAction, Map comparators, String[] sortableColumns) {
          init(table, sortAction, comparators, sortableColumns);
      * Initialisation stuff
     private void init(IWDTable table, IWDAction sortAction, Map comparators, String[] sortableColumns){
          this.table = table;
          if(sortableColumns == null){
               sortableCols = null;
          }else{
               sortableCols = new HashMap();
               for (int i = 0; i < sortableColumns.length; i++) {
                    sortableCols.put(sortableColumns<i>, sortableColumns<i>);
          // sanity checks
          if (sortAction == null)
               throw new IllegalArgumentException("Sort action must be given");
          if (table == null)
               throw new IllegalArgumentException("Table must be given");
          if (table.bindingOfDataSource() == null)
               throw new IllegalArgumentException(
                    "Data source of table with id '" + table.getId() + "' must be bound");
          // make the columns sortable
          String dataSourcePrefix = table.bindingOfDataSource() + ".";
          setComparatorsForColumns(dataSourcePrefix, table.iterateGroupedColumns(), comparators);
          //set up the table properties
          table.setOnSort(sortAction);
          table.mappingOfOnSort().addSourceMapping(IWDTable.IWDOnSort.COL, "selectedColumn");
          table.mappingOfOnSort().addSourceMapping(IWDTable.IWDOnSort.DIRECTION, "sortDirection");     
      * Try to make the given columns sortable (recusivly, if necessary)
     private void setComparatorsForColumns(String dataSourcePrefix, Iterator columnIterator, Map comparators){
          int index = 0;
          for (Iterator it = columnIterator; it.hasNext(); ++index) { // for every column: try to make it bindable
               IWDAbstractTableColumn abstractColumn = (IWDAbstractTableColumn) it.next();
               if(abstractColumn instanceof IWDTableColumn){
                    IWDTableColumn column = (IWDTableColumn)abstractColumn;
                    if(sortableCols == null || sortableCols.containsKey(column.getId())){
                         //try to make this column sortable
                         Comparator comparator = null;
                         if (comparators != null){
                              comparator = (Comparator)comparators.get(column.getId());
                         NodeElementByAttributeComparator elementComparator = null;     
                         if (comparator instanceof NodeElementByAttributeComparator) {
                              // the easy one, attribute and ordering are given
                              elementComparator = (NodeElementByAttributeComparator)comparator;
                         } else { // attribute must be determined
                              String bindingOfPrimaryProperty = bindingOfPrimaryProperty(column.getTableCellEditor());
                              if (bindingOfPrimaryProperty == null || !bindingOfPrimaryProperty.startsWith(dataSourcePrefix)){
                                   //no attribute found or outside of data source
                                   column.setSortState(WDTableColumnSortDirection.NOT_SORTABLE);
                                   continue;
                              String attributeName = bindingOfPrimaryProperty.substring(dataSourcePrefix.length());
                              Collection subnodes = new ArrayList();
                              if (attributeName.indexOf('.') >= 0){
                                   //attribute not immediately below data source
                                   String[] tokens = tokenize (attributeName, ".");
                                   for(int i=0; i<tokens.length-1; i++){
                                        subnodes.add(tokens<i>);
                                   attributeName = tokens[tokens.length-1];
                              if(subnodes.size() == 0){
                                   elementComparator = new NodeElementByAttributeComparator(attributeName, comparator);
                              }else{
                                   elementComparator = new NodeElementByAttributeComparator(attributeName, comparator, subnodes);
                         // set up internal data structures
                         comparatorForColumn.put(column, elementComparator);
                         //set sort state
                         column.setSortState(WDTableColumnSortDirection.NONE);
                    }else{
                         //column should not be sortable
                         column.setSortState(WDTableColumnSortDirection.NOT_SORTABLE);
               }else if (abstractColumn instanceof IWDTableColumnGroup){
                    //it's just a column group -> try to bind the columns of the column group
                    IWDTableColumnGroup columnGroup = (IWDTableColumnGroup)abstractColumn;
                    setComparatorsForColumns(dataSourcePrefix, columnGroup.iterateColumns(), comparators);
      * Tokenizes the input string according to the given delimiters. The delimiters will be left out.
      * Example: tokenize("Hello_World", "_") results ["Hello", "World"]
     private String[] tokenize (String input, String delim){
          StringTokenizer tokenizer = new StringTokenizer(input, delim);
          String[] tokens = new String[tokenizer.countTokens()];
          int index = 0;
          while(tokenizer.hasMoreTokens()){
               tokens[index] = tokenizer.nextToken();
               index++;
          return tokens;
      * This method must be called from the event handler of this table sorter's
      * sort action. It performs the actual sort operation.
     public void sort(IWDCustomEvent wdEvent, IWDNode dataSource) {
          // find the things we need
          String columnId = wdEvent.getString("selectedColumn");
          String direction = wdEvent.getString("sortDirection");
          IWDTableColumn column = (IWDTableColumn) table.getView().getElement(columnId);
          NodeElementByAttributeComparator elementComparator = (NodeElementByAttributeComparator) comparatorForColumn.get(column);
          if (elementComparator == null){
               //not a sortable column
               column.setSortState(WDTableColumnSortDirection.NOT_SORTABLE);
               return;
          // sorting
          elementComparator.setSortDirection(WDTableColumnSortDirection.valueOf(direction));
          dataSource.sortElements(elementComparator);
      * Returns the binding of the given table cell editor's property that is
      * considered "primary" or <code>null</code> if no such binding exists or no
      * such property can be determined.
     private static final String bindingOfPrimaryProperty(IWDTableCellEditor editor) {
          return editor instanceof IWDViewElement ? bindingOfPrimaryProperty((IWDViewElement) editor) : null;
      * Returns the binding of the given view element's property that is
      * considered "primary" or <code>null</code> if no such binding exists or no
      * such property can be determined.
     private static final String bindingOfPrimaryProperty(IWDViewElement element) {
          if (element instanceof IWDAbstractDropDownByIndex)
               return ((IWDAbstractDropDownByIndex) element).bindingOfTexts();
          if (element instanceof IWDAbstractDropDownByKey)
               return ((IWDAbstractDropDownByKey) element).bindingOfSelectedKey();
          if (element instanceof IWDAbstractInputField)
               return ((IWDAbstractInputField) element).bindingOfValue();
          if (element instanceof IWDCaption)
               return ((IWDCaption) element).bindingOfText();
          if (element instanceof IWDCheckBox)
               return ((IWDCheckBox) element).bindingOfChecked();
          if (element instanceof IWDLink)
               return ((IWDLink) element).bindingOfText();
          if (element instanceof IWDProgressIndicator)
               return ((IWDProgressIndicator) element).bindingOfPercentValue();
          if (element instanceof IWDRadioButton)
               return ((IWDRadioButton) element).bindingOfSelectedKey();
          if (element instanceof IWDTextEdit)
               return ((IWDTextEdit) element).bindingOfValue();
          if (element instanceof IWDTextView)
               return ((IWDTextView) element).bindingOfText();
          return null;
      * Instance of a comparator according to the ordering imposed by the
      * implementation of <code>Comparable</code>.
     private static final Comparator DEFAULT = new Comparator() {
           * Compares the given objects according to the ordering imposed by the first
           * ones <code>compareTo(Object)</code> function. Furthermore, <code>null</code>
           * is treated to be less than any object.
           * @see java.lang.Comparable#compareTo(java.lang.Object)
           * @see java.util.Comparator#compare(java.lang.Object, java.lang.Object)
          public int compare(Object o1, Object o2) {
               if (o1 == null && o2 == null)
                    return 0;
               if (o1 == null)
                    return -1;
               if (o2 == null)
                    return +1;
               if (o1 instanceof Boolean && o2 instanceof Boolean)
                    return o1.toString().compareTo(o2.toString()); // false < true
               if (o1 instanceof String && o2 instanceof String){
                    //Use a Collator for sorting according to the given Locale
                    Collator collate = Collator.getInstance(WDResourceHandler.getCurrentSessionLocale());
                    return collate.compare(o1, o2);                    
               return ((Comparable) o1).compareTo((Comparable) o2);
      * Map of table column to comparator (<code>ReversableComparator</code>)
      * used for sorting that column (sortable columns only).
     private Map comparatorForColumn = new HashMap();
      * The table to be sorted.
     private IWDTable table = null;
      * Column-IDs of the columns, which should be sortable
     private Map sortableCols = null;
      * Generic comparator that compares node elements by a given attribute with
      * the help of a given comparator.
     public final class NodeElementByAttributeComparator implements Comparator {
           * Creates a new comparator for the given attribute name that compares values
           * of that attribute according to the natural ordering of that attribute's
           * type (which must implement <code>java.lang.Comparable</code>).
          public NodeElementByAttributeComparator(String attributeName) {
               this(attributeName, null, false, new ArrayList());
           * Creates a new comparator for the given attribute name that compares values
           * of that attribute with the help of the given comparator. If no comparator
           * is given, the natural ordering of that attribute's type is used.
          public NodeElementByAttributeComparator(String attributeName, Comparator comparator) {
               this(attributeName, comparator, false, new ArrayList());
           * Creates a new comparator for the given attribute name that compares values
           * of that attribute either as objects (i.e. "in internal format") or as text
           * (i.e. "in external format") as indicated. The ordering is the natural
           * ordering of that attribute's type (which must implement
           * <code>java.lang.Comparable</code>) in case objects are compared or the
           * natural ordering of <code>java.lang.String</code> in case texts are compared.
          public NodeElementByAttributeComparator(String attributeName, boolean compareAsText) {
               this(attributeName, null, compareAsText, new ArrayList());
           * Creates a new comparator for the given attribute name that compares values
           * of that attribute according to the natural ordering of that attribute's
           * type (which must implement <code>java.lang.Comparable</code>). In addition it is possible
           * to define the path to a child node with the <code>java.util.Collection</code> subnodes.
           * (List of child node names in the correct order)
          public NodeElementByAttributeComparator(String attributeName, Collection subnodes) {
               this(attributeName, null, false, subnodes);
           * Creates a new comparator for the given attribute name that compares values
           * of that attribute with the help of the given comparator. If no comparator
           * is given, the natural ordering of that attribute's type is used. In addition it is possible
           * to define the path to a child node with the <code>java.util.Collection</code> subnodes.
           * (List of child node names in the correct order)
          public NodeElementByAttributeComparator(String attributeName, Comparator comparator, Collection subnodes) {
               this(attributeName, comparator, false, subnodes);
           * Creates a new comparator for the given attribute name that compares values
           * of that attribute either as objects (i.e. "in internal format") or as text
           * (i.e. "in external format") as indicated. The ordering is the natural
           * ordering of that attribute's type (which must implement
           * <code>java.lang.Comparable</code>) in case objects are compared or the
           * natural ordering of <code>java.lang.String</code> in case texts are compared. In addition it is possible
           * to define the path to a child node with the <code>java.util.Collection</code> subnodes.
           * (List of child node names in the correct order)
          public NodeElementByAttributeComparator(String attributeName, boolean compareAsText, Collection subnodes) {
               this(attributeName, null, compareAsText, subnodes);
           * Internal constructor.
          private NodeElementByAttributeComparator(
               String attributeName,
               Comparator comparator,
               boolean compareAsText,
               Collection subNodes) {
               if (attributeName == null)
                    throw new IllegalArgumentException("Attribute name must not be null");
               if (comparator == null)
                    comparator = DEFAULT;
               this.attributeName = attributeName;
               this.comparator = comparator;
               this.compareAsText = compareAsText;
               this.sortDirection = true;
               this.subNodes = subNodes;
           * Sets the sort direction of this comparator to the given direction. The comparator sort in ascending order by default.
           * @see com.sap.tc.webdynpro.clientserver.uielib.standard.api.WDTableColumnSortDirection
          public void setSortDirection(WDTableColumnSortDirection direction){
               if(direction.equals(WDTableColumnSortDirection.UP)){
                    sortDirection = true;
               }else if(direction.equals(WDTableColumnSortDirection.DOWN)){
                    sortDirection = false;
           * Compares the given objects which must be instances of <code>IWDNodeElement</code>
           * according to the values of the attribute given at construction time
           * with the help of the comparator given at construction time.
           * @see java.util.Comparator#compare(java.lang.Object, java.lang.Object)
           * @see com.sap.tc.webdynpro.progmodel.api.IWDNodeElement
          public int compare(Object o1, Object o2) {
               IWDNodeElement element1 = (IWDNodeElement) o1;
               IWDNodeElement element2 = (IWDNodeElement) o2;
               if(subNodes.size() > 0){
                    element1 = getSubNodeElement(element1, 0);
                    element2 = getSubNodeElement(element2, 0);
               Object attributeValue1 = null;
               Object attributeValue2 = null;
               if(element1 != null){
                    attributeValue1 =
                         compareAsText
                              ? element1.getAttributeAsText(attributeName)
                              : element1.getAttributeValue(attributeName);
               if(element2 != null){
                    attributeValue2 =
                         compareAsText
                              ? element2.getAttributeAsText(attributeName)
                              : element2.getAttributeValue(attributeName);
               if(sortDirection){
                    return comparator.compare(attributeValue1, attributeValue2);
               }else{
                    return comparator.compare(attributeValue2, attributeValue1);
           * Determines recursivly the child node, which have an attribute with the given name.
           * The path to this child node must be specified in the subnodes property of this comparator.
           * Start this method with index = 0.
          private IWDNodeElement getSubNodeElement(IWDNodeElement currentElement, int index){
               if(currentElement == null || index >= subNodes.size()){
                    //end of recursion
                    return currentElement;
               }else{
                    return getSubNodeElement(currentElement.node().getChildNode((String)subNodes.toArray()[index], currentElement.index()).getCurrentElement(), index+1);
                    //return getSubNodeElement(currentElement.node().getChildNode((String)subNodes.toArray()[index], currentElement.index()).getElementAt(0), index+1);
           * Name of the attribute used for comparisons.
          private final String attributeName;
           * Comparator used for comparing the attribute's values.
          private final Comparator comparator;
           * Indicates whether attribute values are compared as text (as opposed to
           * "as objects").
          private final boolean compareAsText;
           * Sort direction (true = ascending order, false = descending order)
          private boolean sortDirection;
           * List of child node names
           * (Description of the path from the given context node to the specified attribute)
          private Collection subNodes;

Similar Messages

  • Any specific way to find out the tables being affected by a FormHandler

    Please let me know an approach I can follow to find out the tables being affected on calling a particular Formhandler.

    In our custom implementation, the basic work of a formhandler is to validatate data that came from a form. In our formhandler, we use some manager class and from manager class we call some tool class. In our tool class we will use some repository(In a repository we give definitionFiles=......../xyz.xml). So what operation we are going to perform via form like add, update, delete, show will affect tables in xyz.xml file.
    In OOTB supost we are using ProfileFormHandler so it will affect ProfileAdapterRepository, which has xml file is useProfile.xml.
    -RMishra

  • How to check internal table sorted or not

    Hi all
    I need to check internal table sorted or not which is without header line and having only one field and six values. please let me know how to check it is sorted or not because i need to display message if it is not sorted.
    thanks,
    Minal

    Hi Minal,
    Go through  this info.
    Sorted tables
    This is the most appropriate type if you need a table which is sorted as you fill it. You fill sorted tables using the INSERT statement. Entries are inserted according to the sort sequence defined through the table key. Any illegal entries are recognized as soon as you try to add them to the table. The response time for key access is logarithmically proportional to the number of table entries, since the system always uses a binary search. Sorted tables are particularly useful for partially sequential processing in a LOOP if you specify the beginning of the table key in the WHERE condition.
    Stable sort
    The option
    SORT <itab> ... STABLE.
    allows you to perform a stable sort, that is, the relative sequence of lines that are unchanged by the sort is not changed. If you do not use the STABLE option, the sort sequence is not preserved. If you sort a table several times by the same key, the sequence of the table entries will change in each sort. However, a stable sort takes longer than an unstable sort.
    Examples
    DATA: BEGIN OF LINE,
            LAND(3)  TYPE C,
            NAME(10) TYPE C,
            AGE      TYPE I,
            WEIGHT   TYPE P DECIMALS 2,
          END OF LINE.
    DATA ITAB LIKE STANDARD TABLE OF LINE WITH NON-UNIQUE KEY LAND.
    LINE-LAND = 'G'.   LINE-NAME   = 'Hans'.
    LINE-AGE  = 20.    LINE-WEIGHT = '80.00'.
    APPEND LINE TO ITAB.
    LINE-LAND = 'USA'. LINE-NAME   = 'Nancy'.
    LINE-AGE  = 35.    LINE-WEIGHT = '45.00'.
    APPEND LINE TO ITAB.
    LINE-LAND = 'USA'. LINE-NAME   = 'Howard'.
    LINE-AGE  = 40.    LINE-WEIGHT = '95.00'.
    APPEND LINE TO ITAB.
    LINE-LAND = 'GB'.  LINE-NAME   = 'Jenny'.
    LINE-AGE  = 18.    LINE-WEIGHT = '50.00'.
    APPEND LINE TO ITAB.
    LINE-LAND = 'F'.   LINE-NAME   = 'Michele'.
    LINE-AGE  = 30.    LINE-WEIGHT = '60.00'.
    APPEND LINE TO ITAB.
    LINE-LAND = 'G'.   LINE-NAME   = 'Karl'.
    LINE-AGE  = 60.    LINE-WEIGHT = '75.00'.
    APPEND LINE TO ITAB.
    PERFORM LOOP_AT_ITAB.
    SORT ITAB.
    PERFORM LOOP_AT_ITAB.
    SORT ITAB.
    PERFORM LOOP_AT_ITAB.
    SORT ITAB STABLE.
    PERFORM LOOP_AT_ITAB.
    SORT ITAB DESCENDING BY LAND WEIGHT ASCENDING.
    PERFORM LOOP_AT_ITAB.
    FORM LOOP_AT_ITAB.
      LOOP AT ITAB INTO LINE.
        WRITE: / LINE-LAND, LINE-NAME, LINE-AGE, LINE-WEIGHT.
      ENDLOOP.
      SKIP.
    ENDFORM.
    ************rewords some points if it is helpful.
    Rgds,
    P.Naganjana Reddy

  • Text Overlapping/Wrapping Issue in BSP(Table Sorter Using JQUERY)

    Hi ,
    I have a requirement to add a new column in existing table which has been built by Table Sorter method in JQUERY.
    I have added the new column but the issue is value for the new column is populated  on next line of the table.
    This could be a simple width issue, but i don't know JAVA much.Attached the image for reference.
    Code i have used is:
    <input type="text" name="t_rbclaim[<%= lv_tabix%>].reason" size="3" maxlenth="3" wrapping = "true"
         onBlur="javascript:this.value=this.value.toUpperCase();" value="<%= w_rbclaim-reason%>">
    Please let me know how to modify the above code in better way.

    Hi Raja,
    Can you please help on this problem. I want to know whether there is any funciton module to convert the univercel character set code (HTML Codepage) page to SAP codepage. We are going to use ECC 6.0 which is unicode system for background R/3. So we can get the correct character format if identify the correct conversion method.
    Please let me know if any information and expect some information on this.
    Regards,
    Saravanan V

  • Custom table model, table sorter, and cell renderer to use hidden columns

    Hello,
    I'm having a hard time figuring out the best way to go about this. I currently have a JTable with an custom table model to make the cells immutable. Furthermore, I have a "hidden" column in the table model so that I can access the items selected from a database by their recid, and then another hidden column that keeps track of the appropriate color for a custom cell renderer.
    Subject -- Sender -- Date hidden rec id color
    Hello Pete Jan 15, 2003 2900 blue
    Basically, when a row is selected, it grabs the record id from the hidden column. This essentially allows me to have a data[][] object independent of the one that is used to display the JTable. Instinctively, this does not seem right, but I don't know how else to do it. I know that the DefaultTableModel uses a Vector even when it's constructed with an array and I've read elsewhere that it's not a good idea to do what I'm trying to do.
    The other complication is that I have a table sorter as well. So, when it sorts the objects in the table, I have it recreate the data array and then set the data array of the ImmutableTableModel when it has rearranged all of the items in the array.
    On top of this, I have a custom cell renderer as well. This checks yet another hidden field and displays the row accordingly. So, not only does the table sort need to inform the table model of a change in the data structure, but also the cell renderer.
    Is there a better way to keep the data in sync between all of these?

    To the OP, having hidden columns is just fine, I do that all the time.. Nothing says you have to display ALL the info you have..
    Now, the column appears to be sorting properly
    whenever a new row is added. However, when I attempt
    to remove the selected row, it now removes a seemingly
    random row and I am left with an unselectable blank
    line in my JTable.I have a class that uses an int[] to index the data.. The table model displays rows in order of the index, not the actual order of the data (in my case a Vector of Object[]'s).. Saves a lotta work when sorting..
    If you're using a similar indexing scheme: If you're deleting a row, you have to delete the data in the vector at the INDEX table.getSelectedRow(), not the actual data contained at
    vector.elementAt(table.getSelectedRow()). This would account for a seemingly 'random' row getting deleted, instead of the row you intend.
    Because the row is unselectable, it sounds like you have a null in your model where you should have a row of data.. When you do
    vector.removeElementAt(int), the Vector class packs itself. An array does not. If you have an array, when you delete the row you must make sure you dont have that gap.. Make a new array of
    (old array length-1), populate it, and give it back to your model.. Using Vectors makes this automatic.
    Also, you must make sure your model knows the data changed:
    model.fireTableDataChanged(); otherwise it has no idea anything happened..
    IDK if that's how you're doing it, but it sounds remarkably similar to what I went thru when I put all this together..

  • Can't add row using table sorter

    I had a jtable with my own mytableModel that implements AbstractTableModel. In mytableModel, I have addRow, removeRow... so I can delete/add row dynamically by calling mytableModel.addRow(..). Everything works fine.
    However, after I added the table sorter and table map (got the code from the tutorial).
    MyTableModel myModel = new MyTableModel();
    TableSorter sorter = new TableSorter(myModel);
    JTable table = new JTable(sorter);
    sorter.addMouseListenerToHeaderInTable(table);
    Now, when i call mytableModel.addRow(..), it doesn't work anymore. It doesn't add a row anymore, why?
    Thank you so much for your help.

    I don't have a addRow method in TableSorter. My addRow method is in myTableModel. So, when I need to addRow, I called myTableModel.addRow, In my addRow method, I have fireTableRowsInserted method. This used to work using integrating with TableSorter.
    Do I need to move all my addRow, addCol....DelRow... to TableSorter? The table data are stored in myTableModel. I guess I really doesn't know how the TableSorter work :(
    Thanks

  • Table.Sort only sorting records in preview pane

    I have the following M query:
    let
        OrgIdParameter = Excel.CurrentWorkbook(){[Name="ClientFilter"]}[Content],
        OrgIdValue = OrgIdParameter{0}[Column2],
        Source = Sql.Database("JOHNSQLD53", "EnterpriseAnalytics"),
        dbo_vFactEngrgServiceLocMonthlyAsOfSnapshot = Source{[Schema="dbo",Item="vFactEngrgServiceLocMonthlyAsOfSnapshot"]}[Data],
        #"Filtered Rows" = Table.SelectRows(dbo_vFactEngrgServiceLocMonthlyAsOfSnapshot, each [BeProspectClientOrgId] = OrgIdValue),
        #"Sorted Rows" = Table.Sort(#"Filtered Rows",{{"SnapshotYear", Order.Ascending}})
    in
        #"Sorted Rows"
    however, the sort is working on the records that show in the preview pane (about 36 records), then the data goes back to being unsorted in the rest of the table when loaded in power pivot (224 rows).
    any idea why?

    I believe that Power Pivot does not reliably preserve the input sort of the data; this is a feature of the data model, not of Power Query.

  • EIT SSHR Table sorting

    Hi all,
    I have successfully personalized the EIT SSHR screen to display one of the configured EIT on a custom responsibility using a custom function(so that I can do personalization on function level without affecting other EIT screens).
    Now my challenge is that, when I click on the menu function, it takes me to the people search page, I do a search and select a employee, then it shows me the list of existing EIT records with an option of add, update and delete. Here, I need to show the existing records in a sorted order. I need the latest entry entered to appear in the top. If this is not possible, it would be great if I can have the table sorted as per one of the segment value.
    Is there a way to do this. Can someone help me in doing this and let me know the steps to do the same.
    Cheers
    Arun

    I think Tomahawk is the way to go here.
    Tomahawk allows sorting of data in the data table.
    For action based on row selection, you need to invoke java script function
    using rowOnClick attribute of t:dataTable and then make a hidden command button "click" from
    the java script.
    Regards,
    Joshua

  • Table sorting

    Hello All,
    I already implement table sorting in my application.How can i trigger a table sort action on a particular column after I have compeleted some other action?
    Thanks

    Use IWDNode.sortElements(Comparator).
    The Comparator instance passed to this method should cast its arguments to the node element interface and compare them by the attribute displayed in the particular column.
    Say your node is named "Employees" and the attribute is "Name" and has type "String", then it looks like
    Comparator comparator = new Comparator()
      public int compare(Object x1, Object x2)
        IEmployeesElement e1 = (IEmployeesElement ) x1;
        IEmployeesElement e2 = (IEmployeesElement ) x2;
        return e1.getName().compareTo(e2.getName());
    node.sortElements(comparator);
    Armin

  • New Version of Table Sorter

    Hi All,
    I require new version of Table Sorter.
    The table sorter that I am using may not be updated.
    It doesn't sort the decimal fields.
    Thanks,
    Nikhil

    >
    satish jhariya wrote:
    > Hi
    >
    > Use this link to access the [TableSorter File|https://www.sdn.sap.com/irj/scn/wiki?path=/display/snippets/tablesorterClassfor+WebDynpro]
    >
    > Best Regards
    > Satish Kumar
    Hi Satish,
    I've just tried to use the updated code you've added to the Wiki and it doesn't appear to be syntactically correct.
    There are two problems I can see - it looks like the Wiki software has corrupted a lot of the code with "Unknown Macro :" added all over the place as well as some special characters being replaced, and some of the lines of code appear to be incomplete.
    Could you please have a look at it and correct so that it works as it's useless at the moment?
    Thanks,
    Gareth.

  • "Old" table sorter for NW04

    Hi all,
    I'm using the "old" table sorter for Web Dynpro on a Netweaver 04 system. Everything is working correctly, but I don't know how to call the sort function without clicking on the Table Header.
    How can I automatically sort my table at runtime, the first time the table is shown?
    Is this possible?

    Hi  Palen
    I do think this facility is introduced with 04s.
    /people/bertram.ganz/blog/2006/03/07/enhanced-web-dynpro-java-tablesorter-for-sap-netweaver-04s
    This weblog says something about it.(Hope you have not read it ye
    Regards
    Pratyush

  • Table.sort - is it broken, or am I doing something wrong?

    sometimes, what should be the last element is not being put in the correct position (last) (all others are in the correct order) - no matter what I do, and I have to resort to this function, which works flawlessly:
    function Table:sort( t, func )
        local tc = self:copy( t ) -- make shallow copy
        tc[#tc + 1] = "___dUmMy___" -- 3 underscores on each side.
        table.sort( tc, func )
        local index = 1
        for i = 1, #tc do
            if tc[i] ~= "___dUmMy___" then
                t[index] = tc[i]
                index = index + 1
            else
                -- skip it.       
            end
        end
        t[#tc] = nil -- shouldn't be necessary, but cheap insurance...
    end
    i.e. add an extra dummy element to the table, then sort it using the same sort function, then remove the dummy element.
    Its like table.sort makes one iteration too few, unless the dummy is there to force it, or something...
    This is driving me crazy!
    Any ideas?

    So, I figured it out.
    Sometimes I want the exact opposite order than is (reliably) possible given the table sort algorithm.
    If, in a table sort function, one replaces:
    return order
    with
    return not order
    (in a perfectly working sort function), it reverses the order of the sort but may not handle the last element properly.
    The reason is this:
    The table sort return value is determining whether to swap two values or not to swap them, it is *not* determining absolute ordering - if it were, then returning true would mean order one way, and returning false would mean order the opposite way.
    Enough talk - test plugin: http://www.robcole.com/_temp/TestLrPlugins/Scratch_LrPlugin_0.0.zip
    (Instructions: In plugin manager, click 'Local Test' button. Source code is in ExtendedManager.lua (tableSortTest function) and Framework/Data/Table.lua (reverseSortCopy method).
    Rob

  • Finding which table generated how much redo

    I'm wondering if we can find from any view that during this period a particular table generated how much amount of redo log , other than logminer ?
    We have a particular application and want to know which tables are generating most of the redo.

    from asktom
    see
    http://asktom.oracle.com/pls/ask/f?p=4950:8:::::F4950_P8_DISPLAYID:477221446020
    and
    http://asktom.oracle.com/pls/ask/f?p=4950:8:::::F4950_P8_DISPLAYID:366018048216
    Nologging only affects very very specific operations. For exmaple, from the
    alter index syntax statement in the SQL reference:
    LOGGING|NOLOGGING
    LOGGING|NOLOGGING specifies that subsequent Direct Loader (SQL*Loader) and
    direct-load INSERT operations against a nonpartitioned index, a range or hash
    index partition, or all partitions or subpartitions of a composite-partitioned
    index will be logged (LOGGING) or not logged (NOLOGGING) in the redo log file.
    In NOLOGGING mode, data is modified with minimal logging (to mark new extents
    invalid and to record dictionary changes). When applied during media recovery,
    the extent invalidation records mark a range of blocks as logically corrupt,
    because the redo data is not logged. Therefore, if you cannot afford to lose
    this index, you must take a backup after the operation in NOLOGGING mode.
    If the database is run in ARCHIVELOG mode, media recovery from a backup taken
    before an operation in LOGGING mode will re-create the index. However, media
    recovery from a backup taken before an operation in NOLOGGING mode will not
    re-create the index.
    An index segment can have logging attributes different from those of the base
    table and different from those of other index segments for the same base table.
    That also explains why the truncate above generated redo -- The statement
    "minimal logging (to mark new extents invalid and to record dictionary
    changes)." explains where that redo comes from. The blocks that were truncated
    were not logged HOWEVER the changes to the data dictionary itself were.
    .

  • In Table Control How to get only a single row .

    Hi
    In Table Control How to get only a single row .I am able to decrease it its height to 4 but then 2 rows is getting dsplayed .I want only one row to be display and 2nd row should be deactivated or not visible.
    regards
    Avik
    Edited by: Julius Bussche on Jan 30, 2009 1:10 PM
    Removed friendly greeting from the subject title

    Hi Avik
    use this code it will help you.
    MODULE passdata OUTPUT.
      READ TABLE it_revision INTO wa_rev INDEX tab_clc-current_line.
      IF sy-subrc = 0.
        LOOP AT SCREEN.
          IF screen-group1 = '111'.      " 111 IS THE GROUP NAME
            screen-input = 1.          " input mode
            screen-active = 1.         " input mode.
            MODIFY SCREEN.
          ENDIF.
        ENDLOOP.
      ELSE.
        LOOP AT SCREEN.
          IF screen-group1 = '111'.       "GROUP NAME
            screen-input = 0.           " display mode
            screen-active = 1.          " DISPLAY MODE.
            MODIFY SCREEN.
          ENDIF.
        ENDLOOP.
      ENDIF.
    ENDMODULE.                 " PASSDATA  OUTPUT
    Make sure in group tou are passing the field name that you want in input mode on the base of other field
    Hope it will help you.
    Thanks
    Arun Kayal.

  • SQL Server 2012 Management Studio:In the Database, how to print out or export the old 3 dbo Tables that were created manually and they have a relationship for 1 Parent table and 2 Child tables?How to handle this relationship in creating a new XML Schema?

    Hi all,
    Long time ago, I manually created a Database (APGriMMRP) and 3 Tables (dbo.Table_1_XYcoordinates, dbo.Table_2_Soil, and dbo.Table_3_Water) in my SQL Server 2012 Management Studio (SSMS2012). The dbo.Table_1_XYcoordinates has the following columns: file_id,
    Pt_ID, X, Y, Z, sample_id, Boring. The dbo.Table_2_Soil has the following columns: Boring, sample_date, sample_id, Unit, Arsenic, Chromium, Lead. The dbo.Table_3_Water has the following columns: Boring, sample_date, sample_id, Unit, Benzene, Ethylbenzene,
    Pyrene. The dbo.Table_1_XYcoordinates is a Parent Table. The dbo.Table_2_Soil and the dbo.Table_3_Water are 2 Child Tables. The sample_id is key link for the relationship between the Parent Table and the Child Tables.
    Problem #1) How can I print out or export these 3 dbo Tables?
    Problem #2) If I right-click on the dbo Table, I see "Start PowerShell" and click on it. I get the following error messages: Warning: Failed to load the 'SQLAS' extension: An exception occurred in SMO while trying to manage a service. 
    --> Failed to retrieve data for this request. --> Invalid class.  Warning: Could not obtain SQL Server Service information. An attemp to connect to WMI on 'NAB-WK-02657306' failed with the following error: An exception occurred in SMO while trying
    to manage a service. --> Failed to retrieve data for this request. --> Invalid class.  .... PS SQLSERVER:\SQL\NAB-WK-02657306\SQLEXPRESS\Databases\APGriMMRP\Table_1_XYcoordinates>   What causes this set of error messages? How can
    I get this problem fixed in my PC that is an end user of the Windows 7 LAN System? Note: I don't have the regular version of Microsoft Visual Studio 2012 in my PC. I just have the Microsoft 2012 Shell (Integrated) program in my PC.
    Problem #3: I plan to create an XML Schema Collection in the "APGriMMRP" database for the Parent Table and the Child Tables. How can I handle the relationship between the Parent Table and the Child Table in the XML Schema Collection?
    Problem #4: I plan to extract some results/data from the Parent Table and the Child Table by using XQuery. What kind of JOIN (Left or Right JOIN) should I use in the XQuerying?
    Please kindly help, answer my questions, and advise me how to resolve these 4 problems.
    Thanks in advance,
    Scott Chang    

    In the future, I would recommend you to post your questions one by one, and to the appropriate forum. Of your questions it is really only #3 that fits into this forum. (And that is the one I will not answer, because I have worked very little with XSD.)
    1) Not sure what you mean with "print" or "export", but when you right-click a database, you can select Tasks from the context menu and in this submenu you find "Export data".
    2) I don't know why you get that error, but any particular reason you want to run PowerShell?
    4) If you have tables, you query them with SQL, not XQuery. XQuery is when you query XML documents, but left and right joins are SQL things. There are no joins in XQuery.
    As for left/right join, notice that these two are equivalent:
    SELECT ...
    FROM   a LEFT JOIN b ON a.col = b.col
    SELECT ...
    FROM   b RIGHT JOIN a ON a.col = b.col
    But please never use RIGHT JOIN - it gives me a headache!
    There is nothing that says that you should use any of the other. In fact, if you are returning rows from parent and child, I would expect an inner join, unless you want to cater for parents without children.
    Here is an example where you can study the different join types and how they behave:
    CREATE TABLE apple (a int         NOT NULL PRIMARY KEY,
                        b varchar(23) NOT NULL)
    INSERT apple(a, b)
       VALUES(1, 'Granny Smith'),
             (2, 'Gloster'),
             (4, 'Ingrid-Marie'),
             (5, 'Milenga')
    CREATE TABLE orange(c int        NOT NULL PRIMARY KEY,
                        d varchar(23) NOT NULL)
    INSERT orange(c, d)
       VALUES(1, 'Agent'),
             (3, 'Netherlands'),
             (4, 'Revolution')
    SELECT a, b, c, d
    FROM   apple
    CROSS  JOIN orange
    SELECT a, b, c, d
    FROM   apple
    INNER  JOIN orange ON apple.a = orange.c
    SELECT a, b, c, d
    FROM   apple
    LEFT   OUTER JOIN orange ON apple.a = orange.c
    SELECT a, b, c, d
    FROM   apple
    RIGHT  OUTER JOIN orange ON apple.a = orange.c
    SELECT a, b, c, d
    FROM   apple
    FULL OUTER JOIN orange ON apple.a = orange.c
    go
    DROP TABLE apple, orange
    Erland Sommarskog, SQL Server MVP, [email protected]

Maybe you are looking for