Announcement

Collapse
No announcement yet.
X
  • Filter
  • Time
Clear All
new posts

    TreeGrid sort by hidden field

    Is it possible to sort by a hidden field in a TreeGrid? In this code sample I am trying to sort by the field sortOrder. Sorting only seems to work if the field is visible. I would prefer not to show the field as it would not be relevant to the user.

    Code:
            TreeGrid treeGrid = new TreeGrid();  
            treeGrid.setCanEdit(false);  
            treeGrid.setLoadDataOnDemand(false);  
            treeGrid.setWidth100();  
            treeGrid.setHeight(400);  
            treeGrid.setDataSource(datasource);  
            treeGrid.setNodeIcon("icons/16/person.png");  
            treeGrid.setFolderIcon("icons/16/person.png");  
            treeGrid.setShowOpenIcons(false);  
            treeGrid.setShowDropIcons(false);  
            treeGrid.setClosedIconSuffix("");  
            treeGrid.setAutoFetchData(true);  
            treeGrid.setShowHeader(true);
            TreeGridField nameField = new TreeGridField("name");  
            TreeGridField sortOrder = new TreeGridField("sortOrder");  
            sortOrder.setName("sortOrder");
            sortOrder.setHidden(true);
            nameField.setCanSort(false);
     
           
            treeGrid.setFields(nameField, sortOrder); 
    		treeGrid.setSortField("sortOrder");
    		treeGrid.setSortDirection(SortDirection.ASCENDING);

    #2
    You can sort the underlying Tree dataset, but right now this would require JSNI - call tree.sortByProperty("fieldName", true/false)

    Comment


      #3
      I found this helpful post about sorting by hidden field.

      treeGrid.setSort(new SortSpecifier[]{new SortSpecifier("fieldName",SortDirection.Ascending)});

      This works.While sorting, this does not check if the field is hidden or not.

      Comment

      Working...
      X