Sorting columns of Tree table structure

Hi ,
We have developed Tree Table structure based on the tutorial, but the data in the columns are not in the right order. Can anyone tell me how to do column sorting for Tree table structure, I know how to do column sorting on normal table structure but that logic does not work for Tree table structures
Appreciate your help
Som

Hi Som,
If you are using TutWD_TreeByNestingTableColumn project as example, this code can help you:
  //@@begin javadoc:onActionSortTree(ServerEvent)
  /** Declared validating event handler. */
  //@@end
  public void onActionSortTree(com.sap.tc.webdynpro.progmodel.api.IWDCustomEvent wdEvent )
    //@@begin onActionSortTree(ServerEvent)
     sort(wdContext.nodeCatalogEntries());
    //@@end
  private void sort(IPrivateTreeTableView.ICatalogEntriesNode catalogEntriesNode) {
       if(null==catalogEntriesNode) return;
     catalogEntriesNode.sortElements(COMPORATOR);
     int size = catalogEntriesNode.size();
     for(int i=0;i<size;i++) {
          sort( catalogEntriesNode.nodeChildCatalogEntries(i) );
  private static final Comparator COMPORATOR = new CatalogEntriesComparator();
  private static class CatalogEntriesComparator implements Comparator {
     public int compare(Object o1, Object o2) {
          IPrivateTreeTableView.ICatalogEntriesElement ot1 = (IPrivateTreeTableView.ICatalogEntriesElement)o1;
          IPrivateTreeTableView.ICatalogEntriesElement ot2 = (IPrivateTreeTableView.ICatalogEntriesElement)o2;
          return Collator.getInstance().compare(     ot1!=null ? ot1.getTITLE() : "",
                                                  ot2!=null ? ot2.getTITLE() : "");
     public boolean equals(Object obj) {
          return false;
Best regards, Maksim Rashchynski.

Similar Messages

  • Resizing Columns in Tree Table

    hi all!
    Iam using TreeTable's in my application. It is already developed by somebody. Now what is my problem is when I try to resize the column the subsequent columns are not resizing.
    Can any body help me out to fix this issue
    Thanks in Advance

    I think you got this code from site na?
    I have already seen this code in the net. But I didn't found mistake in our code. What actually is it was developed by somebody.
    If you don't mind I will send that code can you please observe it for the mistake.
    Here is my code:
    Here all the things beginning:
    private void configureForm()
    setBorder(editor.buildBorder(presenter
    .doGetProperty("vmtp.info.testCaseSelector.title")));
    setLayout(new BoxLayout(this, BoxLayout.Y_AXIS));
    tree = new TestCaseTree(presenter, testCaseIn, testCaseOut);
    ActionTreeTablePanel actionTreeTablePanel = new ActionTreeTablePanel(tree, presenter);
    this.add(actionTreeTablePanel);
    Here is the TestCaseTree.java file:
    public class TestCaseTree extends ActionTreeTable implements TreeExpansionListener
    public TestCaseTree(Presenter presenter, TestCaseTO testCaseIn, TestCaseTO testCaseOut)
    super(presenter, testCaseOut, testCaseOut.getActions(), new TestCaseTreeToolbar(presenter));
    addTreeExpansionListener(this);
    ActionBaseTO.enumerateActions(testCaseOut.getActions());
    * This statement causes tooltip to display for child nodes
    setToolTipText(testCaseIn.getName());
    /* (non-Javadoc)
    * @see javax.swing.JTree#isPathEditable()
    @Override
    public boolean isPathEditable(TreePath path)
    DefaultMutableTreeNode node = (DefaultMutableTreeNode)path.getLastPathComponent();
    DefaultMutableTreeNode parent = (DefaultMutableTreeNode)node.getParent().getParent();
    * Commenting out below lines to enable editing of parameter values for
    * action groups in a test case
    //if(parent != null && parent.getUserObject() instanceof ActionTreeTableNode)
    //if(((ActionTreeTableNode)parent.getUserObject()).getAction().isGroup())
    // return false;
    return super.isPathEditable(path);
    public void setVecTreeStateBookmark(Vector treeState) {
         BookmarkTO bookmark = VmtpSession.getVmtpSession().getBookmark();
         BookmarkItemTO bookmarkItem = bookmark.getLastMarkedItem();
         if (bookmarkItem != null && parentObject != null
         && bookmarkItem.getObjectId() == ((TestCaseTO)parentObject).getId()
         && bookmarkItem.getObjectType() == BookmarkItemType.TESTCASE) {
         bookmarkItem.setTreeState(treeState);
    public void updateVecTreeStateBookmark() {
              BookmarkTO bookmark = VmtpSession.getVmtpSession().getBookmark();
              BookmarkItemTO bookmarkItem = bookmark.getLastMarkedItem();
              Vector rowVec = currentExpandedPath();
              if (bookmarkItem != null
                        && parentObject != null
                        && bookmarkItem.getObjectId() == ((TestCaseTO) parentObject)
                                  .getId()
                        && bookmarkItem.getObjectType() == BookmarkItemType.TESTCASE) {
                   bookmarkItem.setTreeState(rowVec);
    private Vector currentExpandedPath() {
              Vector rowVec = new Vector();
              for (int i = 0; i < getRowCount(); i++) {
                   String expandedPath = null;
                   String currPathExpanded = getPathExpanded(i);
                   if (!currPathExpanded.equals("")) {
                        expandedPath = i + getPathExpanded(i);
                        rowVec.add(expandedPath);
              return rowVec;
    private String getPathExpanded(int row) {
         String str = "";
         TreePath path = getPathForRow(row);
         int noofrows = this.getRowCount();
         for(int i = row; i < noofrows; i++) {
              TreePath currPath = this.getPathForRow(i);
              if(i==row || currPath.isDescendant(path)) {
                   if(this.isExpanded(currPath)) {
                        str = str + "," + (i - row);
         return str;
    public Vector getVecTreeStateBookmark() {
         BookmarkTO bookmark = VmtpSession.getVmtpSession().getBookmark();
         BookmarkItemTO bookmarkItem = bookmark.getLastMarkedItem();
         if (bookmarkItem != null && parentObject != null
         && bookmarkItem.getObjectId() == ((TestCaseTO)parentObject).getId()
         && bookmarkItem.getObjectType() == BookmarkItemType.TESTCASE)
         return bookmarkItem.getTreeState();
         return null;
         public void treeCollapsed(TreeExpansionEvent event) {
              updateVecTreeStateBookmark();
              // TODO Auto-generated method stub
         public void treeExpanded(TreeExpansionEvent event) {
              updateVecTreeStateBookmark();
              // TODO Auto-generated method stub
    Here is ActionTreeTable.java
    public abstract class ActionTreeTable extends JTree
    protected Presenter presenter;
    protected DefaultMutableTreeNode top;
    private ActionTreeTableModel treeModel;
    protected List<ActionTO> actions;
    private ParameterTO selectedParameter;
    private JScrollPane scrollPane;
    protected ActionTreeTableToolbar toolbar;
    protected AbstractToolbarTable selectedTable;
    //A jtableheader to be propogated to the parametertablemodel
    protected JTableHeader                    header;
    * The parent object to actions, such as test case, action group etc.
    protected AbstractTO parentObject;
    private Collection<ParameterTable> tables = new ArrayList<ParameterTable>();
    private int tableWidth = 100;
    public ActionTreeTable(Presenter presenter, AbstractTO parentObject,
              Collection<ActionTO> actions, ActionTreeTableToolbar toolbar)
    super();
    this.parentObject = parentObject;
    this.actions = (List<ActionTO>)actions;
    this.toolbar = toolbar;
    this.presenter = presenter;
    toolbar.setTree(this);
    configureTreeTable();
    * bad programming but needs to be done to adhere to the existing design of the table
    * header and the tree tables
    * @param tableHeader
    public void setHeader(JTableHeader tableHeader) {
         this.header = tableHeader;
         if(header != null && tables.size() >= 1) {
              Object[] currTables = tables.toArray();
              for(int i = 0; i < currTables.length; i++) {
                   ParameterTableLite currLiteTable = (ParameterTableLite)currTables;
                   ParameterTableModel model = currLiteTable.getParameterModel();
                   model.setTableHeader(tableHeader);
         // adding a mouse listener to the header that updates the tree when the
              // mouse is clicked on the header and all the table models are sorted
              // according to the desired column
              tableHeader.addMouseListener(new MouseListener() {
                   public void mouseClicked(MouseEvent e) {
                        repaint();
                   public void mouseEntered(MouseEvent e) {
                        // ignored
                   public void mouseExited(MouseEvent e) {
                        // ignored
                   public void mousePressed(MouseEvent e) {
                        // ignored
                   public void mouseReleased(MouseEvent e) {
                        // ignored
    public JTableHeader getHeader() {
         return header;
    private void configureTreeTable()
    this.setRootVisible(false);
    this.setShowsRootHandles(true);
    this.setMaximumSize(new Dimension(2000, 2000));
    buildTree();
    //expandTreePerBookmark();
    public synchronized boolean buildTree()
    boolean outcome = false;
    addMouseListener(new ActionTreeTableMouseListener(this));
    try {
    top = new DefaultMutableTreeNode(null);
    treeModel = new ActionTreeTableModel(top, actions);
    setModel(treeModel);
    addActionsToRoot(actions);
    if (this.getRowHeight() <= 0)
    // Temporary change to non-zero height
    this.setRowHeight(1);
    this.setRowHeight(0);
    //ActionTreeTableCellRenderer renderer=new ActionTreeTableCellRenderer();
    //System.out.println(renderer.getComponent(1));
    this.setCellRenderer(new ActionTreeTableCellRenderer());
    this.setCellEditor(new ActionTreeTableCellEditor(this));
    this.setEditable(true);
    this.validateTree();
    outcome = true;
    } catch (Exception e) {
    // log.log(Level.SEVERE, "Can't load data", e);
    } finally {
    return outcome;
    * Set the expanded nodes in the tree in the bookmark
    * @param treeExpanded true if tree is expanded, false if tree is collapsed
    public abstract void setVecTreeStateBookmark(Vector treeState);
    * Get tree's previous state from bookmark
    * @return true if tree was previously expanded, false if collpased
    public abstract Vector getVecTreeStateBookmark();
    public void addActionsToRoot(Collection<ActionTO> newActions)
    this.addActionsToTree(newActions, top, false);
    public void addActionsToTree(Collection<ActionTO> newActions, DefaultMutableTreeNode parent, boolean groupActions)
    Iterator iterator = newActions.iterator();
    ActionTO actionTO;
    DefaultMutableTreeNode node;
    ParameterTable parameterTable = null;
    while (iterator.hasNext())
    actionTO = (ActionTO)iterator.next();
    node = new DefaultMutableTreeNode(new ActionTreeTableNode(actionTO));
    if(actionTO.isGroup())
    this.addActionsToTree(actionTO.getActionGroup().getActions(), node, true);
    else
    JPanel tablePanel = new JPanel();
    ParameterTableModel model =
    new ParameterTableModel(actionTO, actionTO,
              ParameterTableModel.MODE_IMPLEMENTATION, presenter);
    if(groupActions)
    model.setGroupAction(true);
    parameterTable = new ParameterTableLite(tablePanel, presenter, model, this);
    parameterTable.setToolbar(toolbar);
    tables.add(parameterTable);
    parameterTable.setAutoResizeMode(JTable.AUTO_RESIZE_ALL_COLUMNS);
    parameterTable.setAutoscrolls(true);
    node.add(new DefaultMutableTreeNode(parameterTable));
    * When creating ActionGroups this will be executed when we are adding new
    * actions to the tree.
    if(newActions != actions && parent == top)
    actions.add(actionTO);
    * Passing -1 as index means that the underlying collection of ActionTOs
    * won't be affected. This has already been taken care of above.
    // treeModel.insertNodeInto(node, parent, parent.getChildCount());
    treeModel.insertNodeInto(node, parent, -1);
    treeModel.reload();
    public void removeActionFromTree(MutableTreeNode node)
    treeModel.removeNodeFromParent(node);
    public void moveActionUp(TreePath path)
    DefaultMutableTreeNode nodeToMove = (DefaultMutableTreeNode)path.getLastPathComponent();
    this.moveAction(nodeToMove, -1);
    public void moveActionDown(TreePath path)
    DefaultMutableTreeNode nodeToMove = (DefaultMutableTreeNode)path.getLastPathComponent();
    this.moveAction(nodeToMove, 1);
    public void moveAction(DefaultMutableTreeNode nodeToMove, int offset)
    treeModel.moveAction(nodeToMove, offset);
    setSelectionRow(treeModel.getIndexOfChild(top, nodeToMove));
    * @param selectedParameter The selectedParameter to set.
    public void setSelectedParameter(ParameterTO selectedParameter)
    this.selectedParameter = selectedParameter;
    public AbstractToolbarTable getSelectedTable()
    TreePath path = this.getSelectionPath();
    if(path != null)
    DefaultMutableTreeNode node = (DefaultMutableTreeNode)path.getLastPathComponent();
    if(node.getUserObject() instanceof JTable)
    return (AbstractToolbarTable)node.getUserObject();
    return null;
    public ParameterTO getSelectedParameter()
    TreePath path = this.getSelectionPath();
    if(path != null)
    DefaultMutableTreeNode node =
    (DefaultMutableTreeNode)path.getLastPathComponent();
    if(node.getUserObject() instanceof AbstractToolbarTable)
    AbstractToolbarTable table =
    (AbstractToolbarTable)node.getUserObject();
    if(table.getSelectedRow() != -1)
    return (ParameterTO)table.getTableModel().getRowData(table.getSelectedRow());
    return null;
    public void collapseTree()
    int row = getRowCount() - 1;
    while (row >= 0)
    collapseRow(row);
    row--;
    public void expandTree()
    int row = 0;
    while (row < getRowCount())
    expandRow(row);
    row++;
    * @return Returns the scrollPane.
    public JScrollPane getScrollPane()
    return scrollPane;
    * @param scrollPane The scrollPane to set.
    public void setScrollPane(JScrollPane scrollPane)
    this.scrollPane = scrollPane;
    public void setEnabled(boolean isEnabled)
    // super.setEnabled(isEnabled);
    setEditable(isEnabled);
    ParameterTable tmpTable;
    for(Iterator i = tables.iterator() ; i.hasNext() ;)
    tmpTable = (ParameterTable)i.next();
    * Commented out below lines to enable editing of parameter values
    * for action groups in a test case
    //if(tmpTable.isGroupAction())
    // tmpTable.setEnabled(false);
    //else
    // tmpTable.setEnabled(isEnabled);
    tmpTable.setEnabled(isEnabled);
    toolbar.setToolbarEnabled(isEnabled);
    public void setBounds(int x, int y, int w, int h)
    clearSelection();
    super.setBounds(x, y, w, h);
    private int calculateTableWidth(JTable table)
    JViewport viewPort = getScrollPane().getViewport();
    int vpW = viewPort.getWidth();
    int tableX = table.getLocation().x;
    return getScrollPane().getWidth() - 80;
    * @return Returns the toolbar.
    public AbstractTableToolbar getToolbar()
    return toolbar;
    * @param selectedTable The selectedTable to set.
    public void setSelectedTable(AbstractToolbarTable selectedTable)
    this.selectedTable = selectedTable;
    /* (non-Javadoc)
    * @see javax.swing.JTree#fireValueChanged(javax.swing.event.TreeSelectionEvent)
    @Override
    protected void fireValueChanged(TreeSelectionEvent event)
    if(getSelectionPath() != null && ((DefaultMutableTreeNode)getSelectionPath().
    getLastPathComponent()).getUserObject()
    instanceof ActionTreeNode && isEditable())
    toolbar.setNodeToolsEnabled(true);
    else
    toolbar.setNodeToolsEnabled(false);
    if(selectedTable != null)
    this.selectedTable.clearSelection();
    super.fireValueChanged(event);
    /* (non-Javadoc)
    * @see javax.swing.JTree#isPathEditable()
    @Override
    public boolean isPathEditable(TreePath path)
    DefaultMutableTreeNode node = (DefaultMutableTreeNode)path.getLastPathComponent();
    if(node.getUserObject() instanceof ActionTreeNode)
    return false;
    return super.isPathEditable(path);
    And finally here is ActionTreeTablePanel.java
    public class ActionTreeTablePanel extends JPanel
    * Width and height is set based on the BoxLayout used by
    * the parent container. This might need to be modified
    * if the parent container layout is changed.
    private final int HEADER_WIDTH = 3000;
    private final int HEADER_HEIGHT = 18;
    private final int FIRST_COLUMN_WIDTH = 41;
    private final int LAST_COLUMN_WIDTH = 60;
    private ActionTreeTable tree;
    private JTable defaultTable = null;
    private Presenter     presenter;
    //a variable to give the reference of the tableheader of the main scrollPane to the
    //parametertablemodel to enable sorting
    //the parametertablemodel implements the view to model technique and makes
    //the necessary changes to the model and captures events for the tableheader
    private JTableHeader header = null;
    * Constructs an <code>ActionTreeTable</code> as a ready component
    * to be used in an application.
    * @param tree
    public ActionTreeTablePanel(ActionTreeTable tree, Presenter presenter)
    this.tree = tree;
    this.presenter = presenter;
    this.buildPanel();
    * Called from the constructor to build the component.
    private void buildPanel()
    setLayout(new BoxLayout(this, BoxLayout.Y_AXIS));
    JScrollPane scrollPane = new JScrollPane(tree);
    scrollPane.setVerticalScrollBarPolicy(
    JScrollPane.VERTICAL_SCROLLBAR_ALWAYS);
    scrollPane.setHorizontalScrollBarPolicy(ScrollPaneConstants.HORIZONTAL_SCROLLBAR_ALWAYS);
    tree.setScrollPane(scrollPane);
    this.add(getDefaultTableInScrollPane());
    //header needs to be the same as the
    tree.setHeader(header);
    this.add(scrollPane);
    if(tree.getToolbar() != null)
    this.add(tree.getToolbar());
    * Helper method to build the header for the <code>ActionTreeTable</code>
    * @return
    private JScrollPane getDefaultTableInScrollPane()
    if(defaultTable == null)
    defaultTable = new JTable();
    final JTableHeader tableHeader = defaultTable.getTableHeader();
    TableColumn column = new TableColumn();
    defaultTable.setMaximumSize(new Dimension(HEADER_WIDTH, HEADER_HEIGHT));
    defaultTable.setPreferredSize(new Dimension(HEADER_WIDTH, HEADER_HEIGHT));
    defaultTable.setSize(new Dimension(HEADER_WIDTH, HEADER_HEIGHT));
    // defaultTable.setAutoResizeMode(4);
    column.setHeaderValue(" ");
    column.setWidth(FIRST_COLUMN_WIDTH);
    column.setMaxWidth(FIRST_COLUMN_WIDTH);
    tableHeader.setAlignmentX(FIRST_COLUMN_WIDTH);
    // tableHeader.set;
    // tableHeader.getColumnModel().addColumn(column);
    for(int i=0 ; i < ParameterTableModel.columnNamesImpl.length ; i++)
    column = new TableColumn(i);
    column.setHeaderValue(presenter.doGetProperty(ParameterTableModel.columnNamesImpl[i]));
    tableHeader.getColumnModel().addColumn(column);
    column = new TableColumn();
    column.setHeaderValue(" ");
    column.setWidth(LAST_COLUMN_WIDTH);
    column.setMaxWidth(LAST_COLUMN_WIDTH);
    // tableHeader.getColumnModel().addColumn(column);
    tableHeader.setResizingAllowed(true);
    tableHeader.setReorderingAllowed(false);
    header = defaultTable.getTableHeader();
    //doing the same changes as before and adjusted the size of the columns manually
    //and the size of the columns do not change by listening to user events.
    TableColumn typeColumn = defaultTable.getColumnModel().getColumn(
    ParameterTableModel.TYPE_COL_ID ); // Empty col
    typeColumn.setWidth(ParameterTable.WIDTH_TYPE_COLUMN );
    typeColumn.setMaxWidth(ParameterTable.WIDTH_TYPE_COLUMN);
    TableColumn requiredColumn = defaultTable.getColumnModel().getColumn(
    ParameterTableModel.REQUIRED_COL_ID); // Empty col
    requiredColumn.setWidth(ParameterTable.WIDTH_REQURIED_COLUMN + FIRST_COLUMN_WIDTH);
    requiredColumn.setPreferredWidth(ParameterTable.WIDTH_REQURIED_COLUMN + FIRST_COLUMN_WIDTH);
    requiredColumn.setMaxWidth(ParameterTable.WIDTH_REQURIED_COLUMN + FIRST_COLUMN_WIDTH);
    TableColumn valueColumn = defaultTable.getColumnModel().getColumn(
    ParameterTableModel.VALUE_COL_ID); // Empty col
    valueColumn.setWidth(ParameterTable.WIDTH_VALUE_COLUMN + LAST_COLUMN_WIDTH);
    valueColumn.setPreferredWidth(ParameterTable.WIDTH_VALUE_COLUMN + LAST_COLUMN_WIDTH);
    valueColumn.setMaxWidth(ParameterTable.WIDTH_VALUE_COLUMN + LAST_COLUMN_WIDTH);
    JScrollPane scrollPane = new JScrollPane(defaultTable);
    scrollPane.setMaximumSize(new Dimension(HEADER_WIDTH, HEADER_HEIGHT));
    scrollPane.setPreferredSize(new Dimension(HEADER_WIDTH, HEADER_HEIGHT));
    scrollPane.setSize(new Dimension(HEADER_WIDTH, HEADER_HEIGHT));
    return scrollPane;
    Please guys help me out. My boss is angry upon me..

  • How to fix the width of sorting column about adf table ?

    I develop project with ADF in jdeveloper.
    When click on the sorting column header in adf table,it will adjust the width of the sorting column header.It will make page shifting.
    How can I do to avoid the adjusting ?
    How can I do to fix the width of soting table header?
    Any hint will be appreciated.
    Thank you!
    Message was edited by:
    user618145

    I have set the column width like this:
    in style.css:
    /** Column Settings **/
    af|column::header-text
    background-color:#F0EDE1;
    color:#000000;
    font-family:Arial,Helvetica,sans-serif;
    font-size:12px;
    font-weight:bold;
    padding-left: 2px;
    padding-right: 2px;
    padding-top: 3px;
    padding-bottom:3px;
    border-color: #B5B5B5;
    WIDTH: 120px;
    af|column::sortable-header-text
    background-color:#F0EDE1;
    color:#000000;
    font-family:Arial,Helvetica,sans-serif;
    font-size:12px;
    font-weight:bold;
    padding-left: 2px;
    padding-right: 2px;
    padding-top: 3px;
    padding-bottom:3px;
    border-color: #B5B5B5;
    WIDTH: 120px;
    and in jsp page,write like this:
    <af:panelBox text="test" width="1000" background="dark" >
    <af:table emptyText="" value="#{ftOverview.listOfTransefersVect}" var="transfers" width="100%" banding="row" bandingInterval="1">
    <af:column sortable="true" sortProperty="transactionId" headerText="#{resources['ft_overview.ref']}" formatType="text" width="39"
    noWrap="true">
    <af:outputText value="#{transfers.transactionId}" escape="false"/>
    </af:column>
    </af:table>
    </af:panelBox>
    but it seems doesn't work well.

  • How to get sequence number for tree level in tree table

    Hi,
    User would like to add a column as "Sequence" in the beginning of tree table. The tree table look like as following:
    Sequence Tasks Date
    1 ItemA
    subItem1 12/31/12
    subItem2 12/31/13
    subItem3 12/31/14
    2 ItemB
    subItem1 12/31/12
    subItem2 12/31/13
    subitem3 12/13/14
    How to add this sequence column in tree table?
    Thanks!
    Susan

    Check this sample:
    <af:form id="f1">
                    <af:treeTable value="#{bindings.Departments.treeModel}" var="node" styleClass="AFStretchWidth"
                                  columnStretching="last" selectionListener="#{bindings.Departments.treeModel.makeCurrent}"
                                  rowSelection="single" id="tt1">
                        <f:facet name="nodeStamp">
                            <af:column id="c1" headerText="Department Name" width="200">
                                <af:outputText value="#{node.index + 1} #{node.DepartmentName}" id="ot1"
                                               visible="#{bindings.Departments.treeModel.depth == 0}"/>
                            </af:column>
                        </f:facet>
                        <f:facet name="pathStamp"></f:facet>
                        <af:column id="c2" headerText="Employee Name">
                            <af:outputText id="ot4" value="#{node.FirstName} #{node.LastName}"/>
                        </af:column>
                    </af:treeTable>
                </af:form>Thanks,
    Navaneeth

  • Cannot sort child rows in multilevel tree table

    Hi,
    I originally hijacked a two-year-old forum thread that was vaguely similar to my issue, but a kind forum moderator split my post away
    (and deleted my other hijack post asking this same question)
    so that my inquiry might be viewable on its own.
    Hopefully someone can pay attention to my issue instead of getting it confused with those other old forum threads.
    So, here we go ...
    Is sorting in a treeTable at a particular level possible? Just want to let you I have tried the following approaches to do this. But it dis not work for me.
    I have tree table with 2 levels. I am trying to sort the child rows based on its column say "Display Sequence".
    User can type in number in this column which contains input text. On value change event of the this field, all the
    child rows in the level 2 need to be sorted. This needs to be done without committing the data. On commit it works,
    because it sorts based on order by clause. I want the child rows to be sorted on value change event. Following
    various approaches I tried.
    TreeModel tModel = (TreeModel)treeTable.getValue();
    SortCriterion sortCriterion = new SortCriterion("DisplaySequence",true);
    List<SortCriterion> sortCriteriaList = new ArrayList<SortCriterion>();
    sortCriteriaList.add(sortCriterion);
    tModel.setSortCriteria(sortCriteriaList);
    The above code does not work, As "DisplaySequence" is not available in the parent view object.
    Here is approach no 2
    JUCtrlHierBinding treeTableBinding = null;
    JUCtrlHierNodeBinding nodeBinding = null;
    JUCtrlHierNodeBinding parentNodeBinding = null;
    JUCtrlHierTypeBinding nodeHierTypeBinding = null;
    Key rowKey;
    Object dispSeqObj;
    Number displaySequence = null;
    Map<Key,Number> keyValueMap = null;
    Set<Key> emptyValueKeySet = null;
    Map<Key,Number> sortedKeyValueMap = null;
    DCIteratorBinding target = null;
    Iterator iter = null;
    int rowIndex = 1;
    RowSetIterator rsi = null;
    Row currentRow = null;
    Row row = null;
    RowKeySet selectedRowKey = lookupTreeTable.getSelectedRowKeys();
    Iterator rksIterator = selectedRowKey.iterator();
    if (rksIterator.hasNext()) {
    List key = (List)rksIterator.next();
    System.out.println("key :"+key);
    treeTableBinding = (JUCtrlHierBinding) ((CollectionModel)lookupTreeTable.getValue()).getWrappedData();
    nodeBinding = treeTableBinding.findNodeByKeyPath(key);
    parentNodeBinding = nodeBinding.getParent();
    //rsi = nodeBinding.getParentRowSetIterator();
    rsi = parentNodeBinding.getChildIteratorBinding().getRowSetIterator();
    keyValueMap = new LinkedHashMap<Key,Number>();
    emptyValueKeySet = new LinkedHashSet<Key>();
    // Gets the DisplaySequence by iterating through the child rows
    while(rsi.hasNext()) {
    if(rowIndex==1)
    row = rsi.first();
    else
    row = rsi.next();
    rowKey = row.getKey();
    dispSeqObj = row.getAttribute("DisplaySequence");
    if(dispSeqObj!=null && dispSeqObj instanceof Number) {
    displaySequence = (Number)dispSeqObj;
    keyValueMap.put(rowKey, displaySequence);
    }else {
    emptyValueKeySet.add(rowKey);
    rowIndex++;
    rowIndex = 0;
    // Sort the numbers using comparator
    DisplaySequenceComparator dispSeqComparator = new DisplaySequenceComparator(keyValueMap);
    sortedKeyValueMap = new TreeMap<Key,Number>(dispSeqComparator);
    sortedKeyValueMap.putAll(keyValueMap);
    rsi.reset();
    nodeHierTypeBinding = nodeBinding.getHierTypeBinding();
    System.out.println("nodeHierTypeBinding :"+nodeHierTypeBinding);
    String expr = nodeHierTypeBinding.getTargetIterator();
    if (expr != null) {
    Object val = nodeBinding.getBindingContainer().evaluateParameter(expr, false);
    if (val instanceof DCIteratorBinding) {
    target = ((DCIteratorBinding)val);
    ViewObject targetVo = target.getViewObject();
    System.out.println("targetVo :"+targetVo);
    targetVo.setAssociationConsistent(true);
    //ri = target.findRowsByKeyValues(new Key[]{rowData.getRowKey()});
    rsi = parentNodeBinding.getChildIteratorBinding().getRowSetIterator();
    //rsi = nodeBinding.getParentRowSetIterator();
    // Rearrange the tree rows by inserting at respective index based on sorting.
    ViewObject vo = nodeBinding.getViewObject();
    iter = sortedKeyValueMap.keySet().iterator();
    while(iter.hasNext()) {
    currentRow = rsi.getRow((Key)iter.next());
    rsi.setCurrentRow(currentRow);
    rsi.setCurrentRowAtRangeIndex(rowIndex);
    //rsi.insertRowAtRangeIndex(rowIndex, currentRow);
    rowIndex++;
    iter = emptyValueKeySet.iterator();
    while(iter.hasNext()) {
    currentRow = rsi.getRow((Key)iter.next());
    rsi.setCurrentRow(currentRow);
    rsi.setCurrentRowAtRangeIndex(rowIndex);
    //rsi.insertRowAtRangeIndex(rowIndex, currentRow);
    rowIndex++;
    rsi.closeRowSetIterator();
    AdfFacesContext.getCurrentInstance().addPartialTarget(treeTable);
    private class DisplaySequenceComparator implements Comparator {
    Map<Key,oracle.jbo.domain.Number> dispSeqMap = null;
    public DisplaySequenceComparator(Map<Key,oracle.jbo.domain.Number> dispSeqMap) {
    this.dispSeqMap = dispSeqMap;
    public int compare(Object a, Object b) {
    Key key1 = (Key)a;
    Key key2 = (Key)b;
    oracle.jbo.domain.Number value1 = dispSeqMap.get(key1);
    oracle.jbo.domain.Number value2 = dispSeqMap.get(key2);
    if(value1.getValue() > value2.getValue()) {
    return 1;
    } else if(value1.getValue() == value2.getValue()) {
    return 0;
    } else {
    return -1;
    In the above code I tried to perform sorting of DisplaySequence values using comparator, then tried to rearrange
    nodes or rows based on sort resurts. But rsi.insertRowAtRangeIndex(rowIndex, currentRow) give
    DeadViewException...unable to find view reference. While setting current row also does not work.
    Approach 3.
    DCIteratorBinding iter1 =
    bindings.findIteratorBinding("childIterator");
    iter1.executeQuery();
    SortCriteria sc = new SortCriteriaImpl("DisplaySequence",false);
    SortCriteria [] scArray = new SortCriteria[1];
    scArray[0] = sc;
    iter1.applySortCriteria(scArray);
    Any help in Sorting Child nodes ADF treeTable is appreciated. Thanks in Advance.
    Abhishek

    Hi Frank,
    Thanks for your reply. I have tried similar approach for sorting tree table child rows based on user specified number and it works. But there is a limitation for this. This sorting works only for read only/transient view object. For updatable view object after sorting, data cannot be saved or updated, as it cannot find the rowid. Here is what I tried
    In the ParentViewImpl class,
    1. overrode the method createViewLinkAccessorRS, so that this method is forcefully executed.
    @Override
    protected ViewRowSetImpl createViewLinkAccessorRS(AssociationDefImpl associationDefImpl,
    oracle.jbo.server.ViewObjectImpl viewObjectImpl,
    Row row,
    Object[] object) {
    ViewRowSetImpl viewRowSetImpl = super.createViewLinkAccessorRS(associationDefImpl, viewObjectImpl, row, object);
    return viewRowSetImpl;
    2. Added the following method, which will be invoked on valueChange of DisplaySequence in child row. Expose this method through client interface. This method accept a parameter i.e. parent row key of the child row.
    public void sortChildRecords(Key parentKey) {
    ViewObject viewObject = null;
    String type = null;
    if(parentKey==null) {
    Row [] row = this.findByKey(parentKey, 1);
    RowSet rowSet = (RowSet)row[0].getAttribute("ChildVO");
    viewObject = rowSet.getViewObject();
    viewObject.setSortBy("DisplaySequence asc");
    }else {
    Row row = getCurrentRow();
    RowSet rowSet = (RowSet)row.getAttribute("ChildVO");
    viewObject = rowSet.getViewObject();
    viewObject.setSortBy("DisplaySequence asc");
    this.setQueryMode(ViewObject.QUERY_MODE_SCAN_DATABASE_TABLES |
    ViewObject.QUERY_MODE_SCAN_ENTITY_ROWS);
    this.executeQuery();
    For custom sort, lets say all the numbers should be display first in ascending order, and null or empty values to be display at the end need to override the getRowComparator method in the ChildViewImpl class,
    Here is the code for the same
    @Override
    public Comparator getRowComparator() {
    SortCriteria sortCriteria = new SortCriteriaImpl("DisplaySequence",false);
    SortCriteria [] sortCriterias = new SortCriteria[1];
    sortCriterias[0] = sortCriteria;
    return new DisplaySequenceComparator(sortCriterias);
    private class DisplaySequenceComparator extends RowComparator {
    public DisplaySequenceComparator(SortCriteria [] sortCriterias) {
    super(sortCriterias);
    public int compareRows(Row row1, Row row2) {
    Object dispSeqObj1;
    Object dispSeqObj2;
    Number dispSeq1 = null;
    Number dispSeq2 = null;
    boolean compareRow1 = true;
    boolean compareRow2 = true;
    if(row1!=null) {
    dispSeqObj1 = row1.getAttribute("DisplaySequence");
    if(dispSeqObj1!=null && dispSeqObj1 instanceof Number) {
    dispSeq1 = (Number)dispSeqObj1;
    }else {
    compareRow1 = false;
    if(row2!=null) {
    dispSeqObj2 = row2.getAttribute("DisplaySequence");
    if(dispSeqObj2!=null && dispSeqObj2 instanceof Number) {
    dispSeq2 = (Number)dispSeqObj2;
    }else {
    compareRow2 = false;
    if(compareRow1 && compareRow2) {
    if(dispSeq1.getValue() > dispSeq2.getValue()) {
    return 1;
    } else if(dispSeq1.getValue() == dispSeq2.getValue()) {
    return 0;
    } else {
    return -1;
    if(!compareRow1 && compareRow2)
    return 1;
    if(compareRow1 && !compareRow2)
    return -1;
    return 0;
    The above solution works properly, and sorts the child tree rows. But while saving the changes, update fails. I also came to know that in-memory sorting is applicable to read-only/transient view objects from some blogs and also mentiond in this link http://docs.oracle.com/cd/E24382_01/web.1112/e16182/bcadvvo.htm
    Is there any way that updatable view objects can be sorted and saved as well?
    Thanks,
    Abhishek
    Edited by: 930857 on May 2, 2012 7:12 AM

  • I am unable to sort multiple columns in a table created in Pages.

    I had been using Appleworks up until I installed Lion and have now switched to iWork. I created a table within a Pages document and am able to sort a single column (using the Table Inspector and choosing Sort from  Edit Rows and Columns) but the Sort option is grayed out when I attempt to sort multiple columns.
    In another post, someone talked about this being a problem if you have merged fields. I do not believe I have done this (to be honest I don't know the function of merging fields).
    This is very frustrating as I was easily able to sort these tables in Appleworks.

    Sharon Anderson wrote:
    Thanks for your quick response! I have been trying that but then found that Numbers would only let me print in landscape view so I had to paste the table back into Pages. Is there a way to print in portrat view (from Numbers?)
    Not so. In the lower left corner of the window, there's an icon that looks like a piece of paper. If you see this:
    you are in Sheet View, or normal, mode. If you see this:
    You are in Print View mode. Now you see the icons for portrait and landscape modes. Click your choice. Then arrange your content to fit the pages as you wish.
    Jerry

  • How to Sort Dimension in Pivot Table via Order Column which is changing like Factual values

    Hi,
    Recently in of our product offerings we got stuck on this following question:
    How to Sort Dimension based on the Order Value which Keeps Changing with Factual Values??
    We have a data source laid out as (example)
    In the above the “Order” columns are changing per
    Company/(DimensionA) for DimesnsionB.
    Instead what we want is: (But only if we can get the following result without putting the “Order” Column in the “Values” Section. 
    If there are any configurations that we can make to our power pivot model for the similar data set so that the
    DimesnionB in this case can be sorted by the Order column, would be greatly helpful to us. 
    Sample File:
    http://tms.managility.com.au/query_example.xlsx
    Thanks
    Amol 

    Hi Amol,
    According to your description, you need to sort dimension members in Pivot Table via order column, and you don't want the order column show on the Pivot table, right?
    Based on my research, we can sort the data on the Pivot table based on one of the columns in that table, and we cannot sort the data based on the columns that not existed on the Pivot table. So in your scenario, to achieve your requirement, you can
    add the column to pivot table and hide it.
    https://support.office.com/en-gb/article/Sort-data-in-a-PivotTable-or-a-PivotChart-report-49efc50a-c8d9-4d34-a254-632794ff1e6e
    Regards,
    Charlie Liao
    TechNet Community Support

  • Af:tree column in af:table

    I have af:tree as a column in an af:table and the expand/collapse functionality of af:tree behaves in a way that it works only on the last row added to the table and moreover while working on the last row it expands/collapses all trees in all other rows. All the other rows won't work at all.
    All rows have their own instance of TreeModel. Any clue why this happens ? Does anybody use af:tree as a column in a table ?
    JDev/ADF 10.1.3.3.0.4157
    Thanks for any help
    <af:table binding="#{bean.table}"
    value="#{bean.listTree}"
    banding="row" bandingInterval="1"
    var="row">
    <f:facet name="selection">
    <af:tableSelectMany binding="#{editor.component}"
    text=""
    shortDesc="Select">
    </af:tableSelectMany>
    </f:facet>
    <af:column id="treeLogCol" headerText="Tree" sortable="false">
    <af:tree id="treeLog"
    var="sel" value="#{row.testModel.model}"
    disclosureListener="#{bean.testDisclosureListener}"
    focusRowKey="#{row.testModel.model.focusRowKey}">
    <f:facet name="nodeStamp">
    <af:commandLink text="#{sel.label}" action="#{sel.getOutcome}"/>
    </f:facet>
    </af:tree>
    </af:column>
    </af:table>

    A workaround that seems to work fine is to define a disclosureListener as following -
    public void testDisclosureListener(DisclosureEvent disclosureEvent)
    CoreTree tree = (CoreTree)disclosureEvent.getComponent();
    TableRowWrapper row =
    (TableRowWrapper) ((UIXTable) _table).getRowData();
    PathSet set = tree.getTreeState();
    try
    set.setTreeModel(row.getTreeModel());
    catch(Exception e)
    if (disclosureEvent.isExpanded())
    set.add();
    else
    set.remove();
    // comment the following row since it will expand/collapse all trees in the column
    // AdfFacesContext.getCurrentInstance().addPartialTarget(_table);
    }

  • Default column sort order for 11g table

    Could anyone give me some indication on how I would go about setting the default sort order for a table?
    I have a table with a few columns, and dataset returns in a particular order, but my table decides to sort if in any given order until I manually click on the column header and sort it.
    I would like to have it done by default on a particular field.
    Any info is appreciated.
    Thanks
    Jonny

    As Chris says, the easiest way and best re-use way is to use the order-by clause in your underlying model layer SQL query. For instance in ADF BC this would be in a View Object's query.
    However as you haven't dictated your model layer technology, there is another way in JDev 11g. In your web page that contains the ADF Faces RC table, select the binding tab at the bottom of the page, then double click on the iterator in the binding page, and in the Edit Iterator Binding dialog, select the Sort Criteria tab. This allows you to override the sort order on the iterator's columns.
    CM.

  • ADF Tree Table - Multiple Commandlinks in one column

    Hi,
    We are building a hierarchy using tree table. The hierarchy looks as follows
    +Root Object
    ++ Child Object One
    +++ Child 1.1
    +++ Child 1.2
    +++ Child 1.3
    ++ Child OBject Two
    At each level, the object is used by more than one users. We want to display the list of users who are using that object in one the column called "Users". We want to provide hyperlink to each of the user that is displayed here. So my question so how do we build set of af:commandlinks with in one column? Or is there any other way this problem can be solved? What is ADF recommended pattern here?
    Thanks,

    How about putting a af:panelGroupLayout in the column and add multiple af:commandLinks into the panel=
    Timo

  • Copy table structure with default column values

    Hi....
    I created a table by copying another table structure by using below query.....
    SQL> CREATE TABLE SAMPLE_TEMP AS SELECT * FROM SAMPLE WHERE 1=2;
    But my problem is " the default column values are not copied to new table"
    Suggest a query like that it should " copy a table structure and default values on columns "
    Thanks in advance

    hi,
    One more option would be "dbms_redefinition' - it would work as per your requirement.
    refer further to documentation : http://download.oracle.com/docs/cd/B19306_01/appdev.102/b14258/d_redefi.htm
    - Pavan Kumar N

  • How to create tree table with column headers

    hi,
    when i drag and drop a view object onto my .jspx page as a af: tree table ,
    am not able to get the column header of each column. all the columns in the table are just clubbed together not separated as in af:table.
    can anyone say how the column headers are created for the columns when we drop a view object as a tree table?

    Hi,
    this is not an option with the treeTable as it gets rendered by default when dragging and dropping the collection to the page. I haven't tried it, but I think you will have to check which node is getting rendered and based on this information add your own row layout . Sounds like a bit of coding work
    Frank

  • Sort functionality using MULTIPLE columns in a table control

    Hi all,
    I have a custom screen with table control.Now i need to provide SORT functinality in this screen for the columns in the table control.
    My questins:
    1.Is it possible to seelct MULTIPLE columns in a table control for SORTING?If yes,what explicit settings do i need to do while creatng the TABEL CONTROL in the screen?DO I need to select "Column selection " as MULTIPLE??
    2.How do I write the code for SORT functinonality for multiple columns?
    I know how to write the code for SORTING on basis of single column .
    Thanks!

    Hi Rob,
    Thanks for the reply.
    However I was thinking to apply the same logic as for single columns as follows:
    types : begin of ty_fields,
                c_fieldname(20),
               end of ty_fields.
    data  : t_fields type table of ty_fields,
               wa_fields like line of t_fields.
    WHEN 'SORTUP'.(Ascending)
          loop at TABLE tc01-cols INTO wa_tc01  where  selected = 'X'.
          SPLIT wa_tc01-screen-name AT '-' INTO g_help g_fieldname.
          wa_fields-c_fieldname = g_fieldname.
          append wa_fields to t_fields.
          endloop.
          describe table t_fields lines l_index.
          c_count = 1.
          if c_count  <= l_index.
          read table t_fields into wa_fields index c_count.
          case c_count.
          when '1'.
          l_field1 = wa_fields-c_fieldname.
          when '2'.
         l_field2 = wa_fields-c_fieldname.
        and so on depending on the no of columns in the table control...
          endcase.
          endif.
          SORT t_tvbdpl_scr BY  l_fields1 l_fields 2......l_fieldn.
    Let me know if the above method will work!Also for the above method to work will the type of fields(columns on whihc sort function will be applied) matter???
    Thanks again for your time.

  • Creating a simple 3 column table structure

    Good afternoon.
    I have been trying to create a simple 3 column table structure. A task which should typically take no longer than 15 minutes to design and populate has taken over two hours! (The final structure is acceptable but not ideal).
    Creating the design whilst applying the style Default Table Style - Light,  the content of each column and row are all equally aligned.
    However, when applying either of these styles; Table Style 1 - Clear or
    Table Style 2 - Light Banded,  (light banded is my preference) the alignment of each column and row 'fall apart'. I.e. the content within the left column displays half way down the page, the content within the middle column  at the top
    and the content within the right column at the bottom of the page???
    Adding and removing carriage returns help to a degree but is not ultimately agreeable to achieving an equally structured table design.
    I am rather new to SharePoint design and after exhausting all efforts and considerable time, I need to request assistance please.
    Thank you.
    David
    Senninha010

    Thank you so much!
    Such a simple yet effective solution. :)
    The table structure created in Word retains it's integrity when pasted into a SharePoint page.
    Is there anyway I can also retain the background colour of individual table columns? Specifying such colours in Word; this feature is lost when the table is pasted into a SharePoint page.
    Senninha010

  • Sort the columns of a table

    Hi,
    There is a table with lot of data. I want to change the order in which the columns are displayed when the table is queries. Is there any way or i just have to drop the table and recreate again.
    Have a nice day.
    Thank you
    PK

    Hi,
    Like user637951 said, you only need to change the order in your query. Example:
    Connected to Oracle Database 10g Express Edition Release 10.2.0.1.0
    Connected as hr
    SQL> desc employees;
    Name           Type         Nullable Default Comments                                                                                                                                                                                 
    EMPLOYEE_ID    NUMBER(6)                     Primary key of employees table.                                                                                                                                                          
    FIRST_NAME     VARCHAR2(20) Y                First name of the employee. A not null column.                                                                                                                                           
    LAST_NAME      VARCHAR2(25)                  Last name of the employee. A not null column.                                                                                                                                            
    EMAIL          VARCHAR2(25)                  Email id of the employee                                                                                                                                                                 
    PHONE_NUMBER   VARCHAR2(20) Y                Phone number of the employee; includes country code and area code                                                                                                                        
    HIRE_DATE      DATE                          Date when the employee started on this job. A not null column.                                                                                                                           
    JOB_ID         VARCHAR2(10)                  Current job of the employee; foreign key to job_id column of the
    jobs table. A not null column.                                                                                         
    SALARY         NUMBER(8,2)  Y                Monthly salary of the employee. Must be greater
    than zero (enforced by constraint emp_salary_min)                                                                                       
    COMMISSION_PCT NUMBER(2,2)  Y                Commission percentage of the employee; Only employees in sales
    department elgible for commission percentage                                                                             
    MANAGER_ID     NUMBER(6)    Y                Manager id of the employee; has same domain as manager_id in
    departments table. Foreign key to employee_id column of employees table.
    (useful for reflexive joins and CONNECT BY query)
    DEPARTMENT_ID  NUMBER(4)    Y                Department id where employee works; foreign key to department_id
    column of the departments table                                                                                        
    SQL> select e.employee_id, e.first_name, e.last_name from employees e where e.employee_id = 100;
    EMPLOYEE_ID FIRST_NAME           LAST_NAME
            100 Steven               King
    SQL> select e.first_name, e.last_name, e.employee_id from employees e where e.employee_id = 100;
    FIRST_NAME           LAST_NAME                 EMPLOYEE_ID
    Steven               King                              100
    SQL> Regards,

Maybe you are looking for