Announcement

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

    Group by multiple columns

    I'm trying to implement a group by on multiple columns:

    Code:
    final ListGrid listGrid = new ListGrid() {
                    @Override
                    protected MenuItem[] getHeaderContextMenuItems(final Integer fieldNum) {
                        final MenuItem[] items = super.getHeaderContextMenuItems(fieldNum);
                        MenuItem customItem = new MenuItem("Group by Origin, Destination");
                        customItem.addClickHandler(new ClickHandler() {
                            public void onClick(MenuItemClickEvent event) {
                                ((ListGrid)event.getTarget()).groupBy("ORIG","DEST");
                            }
                        });
                        MenuItem[] newItems = new MenuItem[items.length + 1];
                        for (int i = 0; i < items.length; i++) {
                            MenuItem item = items[i];
                            newItems[i] = item;
                        }
                        newItems[items.length] = customItem;
                        return newItems;
                    }
                };
    I create the ORIG, DEST columns like this,

    Code:
    ListGridField origin = new ListGridField("ORIG", 100);
     ListGridField destination = new ListGridField("DEST", 100);
    I have group summary and grid summary enabled on some other columns.

    I don't get anything in the log and especially for LIST GRID component. Am I missing something here ?

    thanks.

    #2
    I just debugged it and found that event.getTarget returns the actual menu column header image. I'm trying to get reference to list grid from event object so that i can invoke groupby method on it.

    thanks.

    Comment


      #3
      Any help on how to access the listgrid inside the onclick function, so that i can call a groupBy(...) method.

      thanks.

      Comment


        #4
        its so simple man!!!

        u r inside the listgrid class

        Code:
        final ListGrid listGrid = new ListGrid() {
                        @Override
                        protected MenuItem[] getHeaderContextMenuItems(final Integer fieldNum) {
                            final MenuItem[] items = super.getHeaderContextMenuItems(fieldNum);
                            MenuItem customItem = new MenuItem("Group by Origin, Destination");
                            customItem.addClickHandler(new ClickHandler() {
                                public void onClick(MenuItemClickEvent event) {
                                  [b]  groupBy("ORIG","DEST");[/b]
                                }
                            });
                            MenuItem[] newItems = new MenuItem[items.length + 1];
                            for (int i = 0; i < items.length; i++) {
                                MenuItem item = items[i];
                                newItems[i] = item;
                            }
                            newItems[items.length] = customItem;
                            return newItems;
                        }
                    };
        u r already inside the listgrid reference object class.. so can directly call it :)
        hop u may be new to java ,go thru basic concepts of java
        Last edited by vinuriyer; 6 Jul 2011, 02:55.

        Comment


          #5
          Pheww, I had never instantiated a class like this (in-line) before. :) !!!

          Comment


            #6
            hi :)

            so u got the group by working ???

            Comment


              #7
              Hi,
              it works fine but after grouping only the innermost total and Grand Total are computed and the outermost group are not computed.
              How could I do to implement the calculation of the subtotals of the intermediate groups.

              Thanks in advance.

              Comment


                #8
                hi,

                provide the code...i'll check it out

                Comment


                  #9
                  thanks, it's working..

                  Its straight forward.. :)

                  Comment

                  Working...
                  X