Announcement

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

    setting grouptree header not working as before in 5.0

    Hi,

    we're using grouped listgrids to display data. We change the group node titles from "Name" to "Name, xx.xx hours" where we get the "xx.xx" value from the group summary field.

    Now, in 5.0 this has stopped working, the title isn't set anymore.

    The code to do this is:
    Code:
    groupNode.setAttribute("singleCellValue", groupNode.getAttribute("groupValue") + ": " + formatter.format(sum, groupNode, 1, 1) + " " + unitName);
    So, basically setting the "singlecellvalue" attribute on the group treenode no longer has any effect, it's not changed on-screen as it was in 4.x.

    I debugged and both the groupvalue and singlecellvalues are still part of the node.


    Have you changed this behaviour? I hope i can still do this some other way?

    #2
    Hi mathias,

    did you already see ListGridField.setGroupValueFunction()?

    Best regards
    Blama

    Comment


      #3
      Hey Blama, thanks for pitching in!

      Yeah seen it, thanks. In my case, i group by user name, and i want to continue doing that.

      I just want the group title (you know, next to the "+") to not just print the user name, i have a custom way i want it to print.

      And prior to 5.0 i could do it as described.

      However, i did see something else when i followed your link, "groupTitleRenderer" which i don't think was there prior to 5. I'll look at that.

      Comment


        #4
        Hi mathias,

        sorry, I meant ListGridField.setGroupTitleRenderer().

        Best regards
        Blama

        Comment


          #5
          I don't get it. Why is the "grouptitlerenderer" a method on a listgridfield.

          If the "setgrouped" and "setgroupbyfield" are methods on the listgrid, shouldn't the "setgrouptitlerenderer" also be for the entire listgrid, not some single listgridfield?

          Comment


            #6
            No, because you can group by all fields of the ListGrid. And different fields might need different groupTitles. See this sample.

            Best regards
            Blama

            Comment


              #7
              Right, i see in the example, if you switch grouping in the grid, you'd want to define different renderers for different columns.

              Thats pretty cool, although my grouping is static.

              I do though, want to access the group summary values, too bad there seems no way to access them easily. I currently do a treenode iteration on the root, like below. Wish there was an easier way.
              Code:
                  private String findGroupSummaryField(Tree tree, TreeNode parent, String attribute) {
                      for (TreeNode node : tree.getChildren(parent)) {
                          if (node.getIsGroupSummary()) {
                              return node.getAttribute(attribute);
                          }
                      }
              
                      return null;
                  }
              I also wish there was an easy way to get hold of the group nodes. I have a dropdown list so that users can filter out specific users. currently i iterate through the grouptree manually to find each node and add the user name to the dropdown list when the grouping is complete.

              Comment


                #8
                Hi mathias,

                why don't you use a new operationBinding with SQL DISTINCT/GROUP BY [all columns] for it or a new DataSource to a database VIEW doing the DISTINCT for you?
                If you want the dropdown list to be limited to entries currently in the ListGrid, you can surly apply the criteria from the ListGrid there as well.
                This would be much more easy to understand IMHO (although it might require more lines of code).

                This is also mentioned in the docs (scroll to the end)

                Another benefit is that (I think) with your current approach you can only offer as filter options the users of rows the ListGrid has already loaded (0-75 in a normal ListGrid, 0-1000 in a normal grouped ListGrid), which would not apply to the other approach.

                Best regards
                Blama

                Comment


                  #9
                  Hey again,

                  well it's complicated, but the short story is:

                  We return the "raw data" to the client, which contains data for different users. We then group it in the client to get the nice tree-node interface, i.e. you can expand and collapse individual users to see the raw rows for just that user. It works well, and also, its nice to let the client browser do the summary calculations.

                  We always load all rows at once for the exact reasons you state, up to 2500 rows in our grouped grids. We check how many rows it will be given the parameters sent in and ask the user to reduce the span if there are too many rows.

                  Comment


                    #10
                    Hi mathias,

                    Ok, but the other approach would still work here (with be benefit of not transferring that much data).

                    On your question of changed behaviour of node.getAttribute(attribute) I can't say anything. If it worked before and now does not, perhaps you can debug into it and see the used javascript property names (assuming they changed?!). Use Chrome + SuperDevMode or a verbose deployed version (gwtc with -draftCompile -style PRETTY). Or wait for Isomorphic to answer.

                    Best regards
                    Blama

                    Comment


                      #11
                      Blama, again thanks for the discussion.

                      Yeah, i'm hoping for Iso to say somthing. Basically, i historically have altered the group headers by

                      groupNode.setAttribute("singleCellValue", xxx);

                      In 5.0, the attribute is still there, but the value doesn't change on-screen like it did in 4.1.

                      Comment


                        #12
                        This isn't a supported capability, but, if you wanted to try to resurrect this hack, we would try:

                        1. calling markForRedraw(), which you don't mention doing

                        2. directly accessing the ListGridRecords for groupNodes once you know their indices

                        Comment


                          #13
                          I call markforredraw, always have.

                          Let me show you the code i have used in smartgwt 3 and 4 to update the group headers dynamically after a datasource fetch, after they have been grouped.

                          I have done it this way, since there was no other way to do it (as you acknowledged in another thread back when i coded this):

                          I would love for it to be a better, official way to get hold of the group nodes, but there you are.

                          As you can see i do call markforredraw, and this code worked before 5.0.
                          Code:
                          @Override
                              public void updateHeadersForGroupedGrid(ListGrid groupedGrid) {
                                  Tree tree = groupedGrid.getGroupTree();
                                  if (tree == null) {
                                      return;
                                  }
                                  //tree.getchildren is the same as getfolders, since the nodes under the root ARE the group nodes :)
                                  for (TreeNode groupNode : tree.getChildren(tree.getRoot())) {
                                      setGroupHeader(tree, groupNode, groupSummaryNameColumn);
                                  }
                                  groupedGrid.markForRedraw();
                              }
                          
                              protected void setGroupHeader(Tree tree, TreeNode groupNode, String groupSummaryNameColumn){
                                  String sum = findGroupSummaryField(tree, groupNode, groupSummaryNameColumn);
                                  if (sum != null) {
                                      groupNode.setAttribute("singleCellValue", groupNode.getAttribute("groupValue") + ": " + formatter.format(sum, groupNode, 1, 1) + " " + unitName);
                                  } else {
                                      groupNode.setAttribute("singleCellValue", groupNode.getAttribute("groupValue"));
                                  }
                              }
                          
                              private String findGroupSummaryField(Tree tree, TreeNode parent, String attribute) {
                                  for (TreeNode node : tree.getChildren(parent)) {
                                      if (node.getIsGroupSummary()) {
                                          return node.getAttribute(attribute);
                                      }
                                  }
                          
                                  return null;
                              }

                          Comment


                            #14
                            From a quick look, the new attribute showGroupSummaryInHeader causes us to explicitly control the singleCellValue behavior for groupNodes, and the ListGridRecord.singleCellValue attribute is not consulted.

                            So if you turn on this mode, this will enable single-cell rendering, but you'll need to use the APIs Blama mentioned to modify the content shown for groupNodes.

                            Comment


                              #15
                              Hey, thanks for answering. However, i do set that attribute (grid.setShowGroupSummaryInHeader(false);), since it's not new, it existed prior to 5.0 when my code worked.

                              Comment

                              Working...
                              X