Sorting of nodes in a treeTable

hi,
i got a problem like that how to make sorting in JtreeTable model.the problem is i am passing i am constructin the JtreeTable model by passing DefaultMutableTreeNode object.which contains Nodename and value.I need to sort only by name.
for example DefaultmutableTreeNode object contains nodename as B,D,F,T and nodevalue is 8,8,6,5
i am displaying this in table as a two columns.
nodename value
--A               8
B 8
C 6
+D               5
I need sorting by nodenames.
one importent thing is am constructing a wholedata in to a DefaultMutableTreeNode and i am passing to a TreeTable model.Any java swing expert please help me with a solution.
samplecode:
for example i am constructing the DefaulrmutableTreeNodeobject like this.
data = new MainData(nodeName,nodevalue);
l_childNode = new DefaultMutableTreeNode(data);
l_childNode.setUserObject(data)
l_rootNode.add(l_childNode);
finally i am constructing a treeTable Model by using this l_rootNode.
Please help me how can make soritng in the treeTable model.
please post any similar examples..
waiting for replay.

Moin David,
ja, die Sortierung wird tatsächlich z.Zt. nicht unterstützt:
Hello @all,
The SAP support has confirmed that sorting in grid with collapseLevel is not supported at this time.
I've opened a new thread in the "SAP Business One Product Development Collaboration "-area.
As I understand the chance of impementing this feature raises the more users support this request there.
So I would like to invite you to answer this thread if you agree that the sorting feature should be implemented:
Thanks!
As a workaround I have added a new column in the SELECT (and DataTable and Grid). This column contains a "composite key" of the CollapseLevel-Cols PLUS(!) the failed sorting column and is named "Collapse4" in this example.
U_Col04 was the column of the grid leafes where the sorting has failed before.
The CollapseLevel must be incremented by 1:
SELECT
U_Col01 AS 'Collapse1',
U_Col02 AS 'Collapse2',
U_Col03 AS 'Collapse3',
U_Col01 + '-' + U_Col02 + '-' + U_Col03 + '-' + U_Col04 AS 'Collapse4'
FROM
etc....
There is nothing to expand in Collapse4 than always ONE row. But Collapse4 is sorted now.
Roland
Edited by: Roland Toschek on Sep 3, 2008 12:32 PM

Similar Messages

  • Sort the Nodes and remove duplicate nodes

    Hello Experts,
    I have a requirement to sort the nodes based on a key value.
    e.g.
    <Node>
        <Key>2<Key>
        <Value1>name1<Value1>
        <Value2>email1<Value2>
    </Node>
    <Node>
         <Key>1<Key>
         <Value1>name2<Value1>
        <Value2>email2<Value2>
    </Node>
    <Node>
         <Key>2<Key>
         <Value1>name3<Value1>
        <Value2>email3<Value2>
    </Node>
    and the Output should be
    <TNode>
         <Key>1<Key>
         <Value1>name2<Value1>
        <Value2>email2<Value2>
    </TNode>
    <TNode>
         <Key>2<Key>
         <Value1>name3<Value1>
        <Value2>email3<Value2>
    </TNode>
    I tried using SortByKey function for Node i.e.
    Key --> SortByKey , Node --> TNode
    But I dont get sorted value for Value1 and Value2.
    Can anybody give solution for this?
    I have around 25000 records as input and there are around 25 values in structure.
    Please help.
    Thanks in advance,
    Beena.

    Beena,
    Here you go. If it doesn't helps then let me know.
    Mapping.
    http://www.flickr.com/photo_zoom.gne?id=2185600055&size=o
    http://www.flickr.com/photo_zoom.gne?id=2185600049&size=o
    http://www.flickr.com/photo_zoom.gne?id=2185600063&size=o
    http://www.flickr.com/photo_zoom.gne?id=2185600067&size=o
    Results
    http://www.flickr.com/photo_zoom.gne?id=2185600075&size=o

  • Sorting the nodes...

    hi group,
    the tree has root.The top root has multiple nodes in it..say suppose..nearly 100 nodes in it..
    for ex:
    abc
    def
    ghi
    jkl
    mno
    pqr
    stu
    vwx
    xyz
    i want to sort these nodes in btn action means it should sort and at the same time it should fix in the root node with sorting order.
    Any body has idea on it??
    shalini.

    if its a DefaultMutableTreeNode, you can get the children Vector (protected variable) and sort it using the Arrays utility class. i think it has a vector or object array sorting method in which you can specify the comparator.
    it might be more useful to override the add() method of your node so that when a node is added, you sort the children so the user never has to explicitly do it.

  • Sorting the nodes of a JTree

    Can anyone tell me how to go about sorting the nodes in a JTree?

    The best way to do it is thru the treemodel. Either adjust the order in a DefaultTreeModel, or create your own TreeModel.

  • How to sort Jtree node?

    Now, I want to sort tree node by increasing.
    for example there are three child node:
    [20 -40][
    10 - 20]
    [30- 60].
    they are added to JTree node by different order.but are shown in increasingorder.
    like this:
    [10 - 20]
    [20 -40][
    [30- 60].
    how to control tree node.

    Implement the Comparable interface in t he userobject class and possibly the toString(0 as well.
    Ex.
    public class UserObject implements java.lang.Comparable{
    public int compareTo(Object obj) throws ClassCastException
    public String toString()

  • Custom Sort for nodes in a hierarchy

    Hi All,
    I would like to know how to sort nodes according to a specific order in a hierarchy. I know at the hierarchy level you can set the StandardHierSort property to a custom property i.e CustSortOrder.
    But for the custom property CustSortOrder, how do i set it up so the nodes in the hierarchy will be sorted according to the custom list?
    Thanks
    R

    This is right out of the MDM_User_guide (Look under Custom Sort Order)
    Custom Sort Order
    Nodes can also be sorted in any explicit custom sort order (although limbs are always sorted
    ahead of leaves.) The sort order can be defined by any property that has a property data type of
    SortOrder. (The SortOrder data type is special case of an Integer data type.) By default, any
    Hyperion MDM installation includes a property called Sort Order (assigned to the Default
    property category) that can be used for this purpose.
    To sort a hierarchy according to the value of a node-level sort order property, the hierarchylevel
    property StandardHierSort must have its value set to point to the appropriate node-level
    property that contains the sort order.
    A custom sort order can also be used that applies only to a specific Hyperion MDM user ID,
    enabling users to customize their display of Hyperion MDM data without impacting other users
    of the same hierarchy. This is controlled by the hierarchy-level property UserHierSort. If this
    property has been set to point to a node-level property that has a data type of Sort Order, then
    this sort order takes precedence over both the StandardHierSort property and the default sort
    order.
    If there is no value assigned to the hierarchy-level property StandardHierSort nor to
    UserHierSort, then the default sort order is applied.
    The value of a custom sort order property can be set in any of the following ways:
    1.Sort order values can be loaded into a node-level sort order property when data is initially
    imported into Hyperion MDM (see following for details.)
    2. Explicit values can be defined for the sort order property for any node.
    If a sort order property has been selected for a hierarchy’s StandardHierSort or UserHierSort
    properties, then the Order Children menu option is available by right-clicking on any node
    in a hierarchy. This opens a dialog box that enables the sort order of limbs and leaves to be
    set graphically.
    3. A node-level sort order property might be defined as Derived, and so might be automatically
    populated with a sort order.

  • How to sort jTree Nodes

    Hi,
    I am interested in whats the easiest way to sort jTree Nodes alphabetically. Is there any Method to do this directly or may i use something like quicksort?
    Thanks for help
    Mirco

    Thanks Hamed,
    Well, I work in your code, and I post here.
      public static DefaultMutableTreeNode sortTree(DefaultMutableTreeNode root) {
                     for (int i =0; i<root.getChildCount()-1; i++) {
                              DefaultMutableTreeNode node = (DefaultMutableTreeNode) root.getChildAt(i);
                            String nt = node.getUserObject().toString();
                            for (int j=i+1;j<=root.getChildCount()-1;j++)
                                     DefaultMutableTreeNode prevNode = (DefaultMutableTreeNode) root.getChildAt(j);
                                        String np = prevNode.getUserObject().toString();
                                System.out.println(nt+" "+np);
                                if (nt.compareToIgnoreCase(np)>0) {
                                               root.insert(node, j);
                                             root.insert(prevNode, i);
                            if (node.getChildCount() > 0) {
                        node = sortTree(node);
                     return root;
        }and this code I used after include in jtree
      public  void jTreeSortingBegin()
              dn = (DefaultMutableTreeNode)treeModel.getRoot();
              treeModel.reload();
              dn = sortTree(dn);
              treeModel.reload(dn);
        }for exemple
      addObject(jTextField1.getText());
            jTreeSortingBegin();

  • How to differentiate parent and child node in af:treeTable ?

    Greetings,
    I have a requirement, I display master child view objects using <af:treeTable> component, When user expands a parent row, I have to make parent row is in read only and expanded(child) row in editable. To accomplish this I have to identify the 'node' whether it belongs to parent or child view object. In this example Tree table binds with EmpVO, There is a view link beteween EmpVO and DepartmentVO.
    <af:treeTable value="#{bindings.EmpVO.treeModel}"
    var="node"
    rowSelection="single" id="tEqSum"
    summary="Employee Summary"
    <af:column sortProperty="#{bindings.EmpVO.hints.LocCity.name}"
    filterable="true" sortable="true" width="90"
    headerText="#{bindings.EmpVO.hints.LocCity.label}"
    id="c3">
    <af:outputText value="#{node.LocCity}" id="ot21"/>
    expandAllEnabled="false">
    </af:treeTable>
    Thanks in Advance,

    Hi,
    You can find out the node depth by using
    #{bindings.<your_tree_binding>.treeModel.depth}Based on the depth, you can decide whether its a parent node or child node (for a 1 level tree- say dept and emp, the depth for parent would be 0 and for the child it would be 1).
    -Arun

  • Sorting XML nodes in Java

    I have a java code that reads various xml files, filters cetain elements and writes the results of these files to one large xml file. Problem is, when the files are read into the large xml, all the nodes are sorted alphabetically. I tried looking for an API that's responsible for this but I cant find one. Can anyone please help?? Here's the portion of my code that writes the file:
             private static void writeFile(Document doc, ArrayList docIdList,
                   BufferedWriter output) {
              try {
                   Element loElmt = null;
                   NodeList loDocumentList = XMLUtil.getNodeList(doc,
                             "/XML_EXPORT_FILE/DOCUMENT");
                   for (int i = 0; i < loDocumentList.getLength(); i++) {
                        Element loDocument = (Element) loDocumentList.item(i);
                        String lsDocCode = loDocument.getAttribute("DOC");
                        String lsDocId = loDocument.getAttribute("DOCS");
                        //System.out.println(lsDocCode + "\t\t" + lsDocId);
                        // doc identifer is in list
                        if (isDocInList(docIdList, lsDocCode, lsDocId)) {
                             String document = XMLUtil.transformToString(loDocument);
                             System.out.println("Writing " + lsDocCode + "\t\t"
                                       + lsDocId + " to output file");
                             output.write(document);
              } catch (Exception e) {
                   e.printStackTrace();
              }

    I have a java code that reads various xml files, filters cetain elements and writes the results of these files to one large xml file. Problem is, when the files are read into the large xml, all the nodes are sorted alphabetically. I tried looking for an API that's responsible for this but I cant find one. Can anyone please help?? Here's the portion of my code that writes the file:
             private static void writeFile(Document doc, ArrayList docIdList,
                   BufferedWriter output) {
              try {
                   Element loElmt = null;
                   NodeList loDocumentList = XMLUtil.getNodeList(doc,
                             "/XML_EXPORT_FILE/DOCUMENT");
                   for (int i = 0; i < loDocumentList.getLength(); i++) {
                        Element loDocument = (Element) loDocumentList.item(i);
                        String lsDocCode = loDocument.getAttribute("DOC");
                        String lsDocId = loDocument.getAttribute("DOCS");
                        //System.out.println(lsDocCode + "\t\t" + lsDocId);
                        // doc identifer is in list
                        if (isDocInList(docIdList, lsDocCode, lsDocId)) {
                             String document = XMLUtil.transformToString(loDocument);
                             System.out.println("Writing " + lsDocCode + "\t\t"
                                       + lsDocId + " to output file");
                             output.write(document);
              } catch (Exception e) {
                   e.printStackTrace();
              }

  • Sorting FTREE nodes

    is there a way to populate a FTREE object such that the nodes are sorted without loss of hierarchy? I read in a note that the "ORDER BY" clause cannot be used. On the other hand, the items are often "shuffled", and it may be hard for the users to retrieve what they are searching.
    Is there some alternative way to obtain it (for example, by splitting the building process level-by-level instead of using a single query)?

    As Andreas suggested, you can use ORDER SIBLINGS BY in your tree query to order the level 2 and up nodes with a specific order.
    Oracle Forms 10g and 9i does support this SQL syntax.
    sample:
    CONNECT BY PRIOR M.NODE_ID = M.NODE_PARENT
      START WITH M.NODE_PARENT IS NULL
    ORDER SIBLINGS BY M.NODE_ORDERTony

  • Issue with child node edit on TreeTable

    Hello,
    I have a treeTable which is based on single VO. My problem is such that, when i select the child node and click on edit, i get values of it's parent :( ....
    but when i have once  edit on any node (either rollback/commit) and hit the browser refresh button now it works as expected and no more issue....
    what the heck is that. I have used backingBean scope and i have jdev 11.1.1.3.0
    Thanks
    Raj

    Hello Frank,
    Thank you so much for the help.. I have 2 iterator as explained in http://www.oracle.com/technetwork/developer-tools/adf/learnmore/sept2011-otn-harvest-508189.pdf .
    As my treeTable is based on single VO , whenever i select a child node and hit the toolbar edit and/or context menu edit, i get parent node info in the edit form. and this happens until i hitting browser refresh. after that it works as expected....
    when selection is made and edit button is clicked i call the managed bean method to call service operation as:
    public void onTreeTableEditClicked(ActionEvent actionEvent)
    Number id = getSelectedIdFromTree(); // my problem is here ... i am getting parent id until once edit is done(either rollback/commit) and browser refresh is hit. after that i am getting selected it.
    if (id!= null)
    OperationBinding opr =
    ADFBindingUtils.getDCBindingContainer().getOperationBinding("selectMyMethod");
    opr.getParamsMap().put("id", id);
    opr.execute();
    _showPopup(getEditPopup());*
    else
    // show warning.
    public Number getSelectedIdFromTree()
    RowKeySet rks2 = myTreeTable.getSelectedRowKeys();
    Iterator rksIterator = rks2.iterator();
    if (rksIterator.hasNext())
    List<Key> list = (List<Key>) rksIterator.next();
    return ((DBSequence) (list.get(list.size() -
    1).getKeyValues()[0])).getSequenceNumber();
    return null;
    // in the application Module
    public void selectMyMethod(Number id)
    MYVOImpl pvo = getEditMyVOImpl();
    MYVORowImpl row =
    (MYVORowImpl ) pvo.findByKey(new Key(new Object[]
    { new DBSequence(id) }), 1)[0];
    pvo.setCurrentRow(row);
    and the edit popup has value referenced by editIterator...
    Please let me know where i am wrong, or is there something i am missing.
    Thank you
    Edited by: MavenDev on Nov 8, 2011 8:34 AM

  • Sorting of Treenodes in a treeTable

    Here goes. I downloaded src.zip from the treetable example from here
    http://java.sun.com/products/jfc/tsc/articles/treetable2/index.html#source_code
    I extracted it to c:\treetable
    Then I downloaded TableMap.java and TableSorter.java from here and put them in a the same directory
    http://java.sun.com/docs/books/tutorial/uiswing/components/table.html#sorting
    I changed these lines in JTreeTable.java
         // Install a tableModel representing the visible rows in the tree.
         super.setModel(new TreeTableModelAdapter(treeTableModel, tree));
    to this
         // Install a tableModel representing the visible rows in the tree with a JSorttable wrapper.
         TableSorter sorter = new TableSorter(new TreeTableModelAdapter(treeTableModel, tree));
         super.setModel(sorter);
         sorter.setTableHeader(getTableHeader());
    but this is not working for Treenodes but its working for other columns.
    but i need to sort treenodes..
    please helpme some java experts regaridng this..please.

    Moin David,
    ja, die Sortierung wird tatsächlich z.Zt. nicht unterstützt:
    Hello @all,
    The SAP support has confirmed that sorting in grid with collapseLevel is not supported at this time.
    I've opened a new thread in the "SAP Business One Product Development Collaboration "-area.
    As I understand the chance of impementing this feature raises the more users support this request there.
    So I would like to invite you to answer this thread if you agree that the sorting feature should be implemented:
    Thanks!
    As a workaround I have added a new column in the SELECT (and DataTable and Grid). This column contains a "composite key" of the CollapseLevel-Cols PLUS(!) the failed sorting column and is named "Collapse4" in this example.
    U_Col04 was the column of the grid leafes where the sorting has failed before.
    The CollapseLevel must be incremented by 1:
    SELECT
    U_Col01 AS 'Collapse1',
    U_Col02 AS 'Collapse2',
    U_Col03 AS 'Collapse3',
    U_Col01 + '-' + U_Col02 + '-' + U_Col03 + '-' + U_Col04 AS 'Collapse4'
    FROM
    etc....
    There is nothing to expand in Collapse4 than always ONE row. But Collapse4 is sorted now.
    Roland
    Edited by: Roland Toschek on Sep 3, 2008 12:32 PM

  • Selecting node in af:treeTable

    Hi! My task is to alter custom selection function on af:table and make it work for treeTable. Make current method I took from this tutorial http://www.oracle.com/technetwork/developer-tools/adf/learnmore/25-generic-tree-selection-listener-169164.pdf
    And here is a method that I have to change:
    public void TblStagesOnSelect(SelectionEvent selectionEvent) {
    GeneralFunction.makeCurrent(selectionEvent);
    if(treeTable.getRowAtRangeIndex(treeTable.getCurrentRowIndex()).getAttribute("IdParentStage") == null){
    parentUser.setAttributeValue(tf_idUserRespRequest.getValue());
    } else{
    for (int i=0;i<=treeTable.getEstimatedRowCount()-1;i++){
    if (treeTable.getRowAtRangeIndex(treeTable.getCurrentRowIndex()).getAttribute("IdParentStage").equals(treeTable.getRowAtRangeIndex(i).getAttribute("IdStage")))
    parentUser.setAttributeValue(treeTable.getRowAtRangeIndex(i).getAttribute("IdUserResp"));
    break;
    This method was written for table, but it doesn't work on treeTable. Can anyone help?

    did u check this
    Jdeveloper,Oracle ADF &amp;amp; Java: Tree Table Component in Oracle ADF(Hierarchical Representation)
    http://www.oracle.com/technetwork/developer-tools/adf/learnmore/26-get-selected-tree-node-data-169165.pdf

  • How to sort master-node in master-detail scenario without losing subnodes?

    Hi,
    I've a master-detail scenario and want to sort my master node.
    How can I sort the master node without losing the detail-subnodes?
    If I take a look in class CL_WDR_TABLE_METHOD_HNDL and method  IF_WD_TABLE_METHOD_HNDL~APPLY_SORTING
    Sorting is done by
    - unload node with context_node->get_static_attributes_table into an internal table
    - keeping node state like lead_selection(s) and attribute_properties
    - sort internal table
    - bind internal table to node
    - set lead_selection and properties
    But all subnodes are gone.
    How do you sort a master node?
    Thanks and Regards
    Carsten

    I think you have to write your own logic for that . May be you can implement IF_WD_TABLE_METHOD_HNDL in your class and extend the current logic to support subnodes.

  • Sorting a node and table

    can any one tell, How to sort a dynamically generated table and dynamically generated node?

    Thanks Anja,
    I am custamizing MSS Approve/Review timesheets iview.
    in that i need to sort the table based on attendence type(meal period hours , attendence hours,etc are att types) and
    display subtotals for each attendence type. That is in webdynpro java.

Maybe you are looking for

  • No partitions found ! error while deploying a soa composite from jdev

    Hi, I have an issue while deploying a composite from Jdev. After selecting the server I am getting "No partitions found!" error in the SOA Servers step of the Deployment. Followed this link ( Re: JDev PS2 (10.3.3) can't deploy SOA to WLS PS1 (10.3.2)

  • Emailing the photo files as an attachment, not the opened photo

    When I export a photo to email I will get the actual photo in opened format in the text part of the email, and not a file name attached to the email. I use a iMac OS X version 10.6.7. How can I change to attaching the photo files? Thanks for your hel

  • Interfacing StyledDocument and XML

    Hello, I'm trying to make an xml editor, but am stumped on the javax.swing.text.StyledDocument interface. The problem is that DefaultStyledDocument isn't suited to store xml, and HTMLStyledDocument is well, html. What I want is a document class that

  • AMFPHP and Flex 2 B3

    I'm trying to do the AMFPHP tutorial in the Labs wiki and am running into errors. Any ideas what is happening? Here's the tutorial Link to Wiki I'm getting an error on this line: public var gateway : RemotingConnection; And the error is: Type was not

  • VIRUS IN BLACKBERRY TORCH

    Hi Everyone, M new to this forum and aprreciate if someone could help on the subject. i m a user of BB Torch in Msia. last month my service provider (celcom) charge me 210 for GPRS usage due large MMS sent which I never did. After complaining they wa