Announcement

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

  • Jkike
    replied
    Hi,

    I managed to have both the title group header and the summaryGroupRow visibile when the group is collapse.

    Of course, it is not the best solution at all, but it is the best I could get to.

    First, I set the grid to have the summary visible in the header and not to build the extra column for the group title (I need all the space for the meaningful data):

    Code:
    grid.setShowGroupSummary(true);
    grid.setShowGroupSummaryInHeader(true);
    grid.setShowGroupTitleColumn(false); //no extra column!!
    Then I intercept the groupBy event and build an extra row for the title, just above the original row that contains the summaries:

    Code:
    grid.addGroupByHandler(new GroupByHandler() {
    
       @Override
       public void onGroupBy(GroupByEvent event) {
             Scheduler.get().scheduleDeferred(new ScheduledCommand() {
                  @Override
                  public void execute() {
                     addTitleRow();
                   }
             });
    
        }
    });
    
    //Need to memoriez the added nodes
    Set<TreeNode> fakeNodes = new HashSet<TreeNode>();
    
    protected void addTitleRow() {
     if (grid.getGroupTree() == null) {
      return;
     }
     //Need to remove the added row, or they may be duplicated
     for (TreeNode fake : fakeNodes) {
      grid.getGroupTree().remove(fake);
     }
     fakeNodes.clear();
    
     TreeNode parent = grid.getGroupTree().getRoot();
     TreeNode[] originalFolder = grid.getGroupTree().getDescendantFolders();
     int pos = 0;
     for (TreeNode nt : originalFolder) {
          TreeNode head = new TreeNode();
          Object title = nt.getAttributeAsObject("groupValue");
          head.setSingleCellValue(nt.getAttributeAsObject("groupValue"););
    
          head.setAttribute("groupFakeTitleRow", Boolean.TRUE);
          head.setCustomStyle("groupFakeTitleRow");
          head.setCanExpand(false);
          head.setIsGroupSummary(true);
          head.setIsFolder(true);
          head.setEnabled(false); //It cannot be clicked nor selected
                
          grid.getGroupTree().add(head, parent, pos);
          fakeNodes.add(head);
          pos += 2;
     }
    }
    Then, when I start to do some action on the grid, I had to add an handler also for the sorting, since the added rows where moved at the top or the bottom of the list.

    Code:
    grid.addSortChangedHandler(new SortChangedHandler() {
       @Override
       public void onSortChanged(SortEvent event) {
         final String[] fields = grid.getGroupByFields();
         grid.groupBy();
    
          fakeNodes.clear();
          Scheduler.get().scheduleDeferred(new ScheduledCommand() {
              @Override
              public void execute() {
                    grid.groupBy(fields);
             }
          });
      }
    });
    This solution, if we can call it so, work well enough with grid having not too many records (let's say less than 150), although I don't like at all to have to ungroup and then group again the grid when the user do a sort. I think I can always disable the sorting if the grid gets grouped and then re-enable it when the group is removed...

    At this point, I wonder if there is a way I can act directly on the piece of code that build the "summaryGroupRow", from the beggining, but I have no idea on how this can be achived.

    I attach a screenshot of the resulting grid.

    Thank you,
    Barbara
    Attached Files

    Leave a comment:


  • Jkike
    replied
    Displaying group summary when group is collapsed

    Hi,

    I also have some users who ask me to have the summary visible even if the group is collapsed.

    Since the group title is very long, and I must show it, I have to set the grid with following configuration:

    Code:
    grid.setShowGroupTitleColumn(false);
    grid.setShowGroupSummaryInHeader(false);
    If I set grid.setShowGroupTitleColumn(true); then I will end up with a new column that is too large, and the meaningful data will scroll out of view.

    If I set grid.setShowGroupSummaryInHeader(true); then I will end up with the group row whitout the title.

    Unfortunately I cannot even set the title of the group to show up on a specific column, due to the length of the title itself that will, again, make the meaningful columns scroll out of view.

    There is any workaround that may force all the rows with attribute "isGroupSummary" not to be hide when I collapse the parent folder?

    If not, there is any way to intercept the collapse/expand group events?

    Thank you for any help you may give me.

    Leave a comment:


  • Isomorphic
    replied
    There's currently no setting that would cause multiline summary rows to be shown. It makes sense as a possible built-in mode, so consider Feature Sponsorship if it's important enough.

    Leave a comment:


  • Displaying group summary when group is collapsed.

    Hi,

    Is there any way to display a group summary when a group is collapsed? Our users want to be able to collapse groups and just see the 3-line group summaries without seeing the individual records.

    I see you have an option to display a group summary in the header. But, we have a multi-line group summary and it doesn't look like that can be displayed in the group header after trying it in your Feature Explorer.
Working...
X