Announcement

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

  • acamellini
    replied
    I've issues implementing the solution of jsres cause i cannot find the class ListGridAdapter used in this solution. Any Hint of how to get around this?

    Leave a comment:


  • jay.l.fisher
    replied
    I've switched to replacing the Ungroup menu item which actually fits my purposes better. I was getting that missing _1 error consistently though when trying to replace the "Group by" item..

    The difference might be that my code making the call to getGroupByText() was executing inside an override to getHeaderContextMenuItems() after calling super.getHeaderContextMenuItems(fieldNum).

    Not sure if that would make a difference or not.

    Leave a comment:


  • Isomorphic
    replied
    A call to getGroupByText() should work fine (very crude test demonstrating this):
    Code:
            ListGrid foo = new ListGrid();
            SC.say(foo.getGroupByText());
    If you can show us code that fails, we'll be happy to take a look. You could also try hitting the app in compiled mode in Internet Explorer and look for the javascript error stack trace logged in developer console - that might clarify where that missing "_1" is coming from.

    Leave a comment:


  • jay.l.fisher
    replied
    I've implemented this as well, but modified slightly to remove the field from the groupBy list if it is already there or add it if not.

    Is there some way to leverage the full set of standard group by options (i.e. grouping granularity) and still modify the behavior so it adds the new field to the group by list instead of replacing it with the single field?

    Another problem I've run into with this. We need to support I18N so I've changed the logic that replaces the standard Group by ... menu item. I need to check for a match with getGroupByText() instead of looking for a menu title that startsWith("Group by"). But when I make a reference to getGroupByText() I get this error. Any ideas?
    Code:
    16:40:32.054 [ERROR] [ipgui] Uncaught exception escaped
    
    com.google.gwt.core.client.JavaScriptException: (TypeError): _1 is undefined
        at com.google.gwt.dev.shell.BrowserChannelServer.invokeJavascript(BrowserChannelServer.java:237)
        at com.google.gwt.dev.shell.ModuleSpaceOOPHM.doInvoke(ModuleSpaceOOPHM.java:132)
        at com.google.gwt.dev.shell.ModuleSpace.invokeNative(ModuleSpace.java:561)
        at com.google.gwt.dev.shell.ModuleSpace.invokeNativeObject(ModuleSpace.java:269)
        at com.google.gwt.dev.shell.JavaScriptHost.invokeNativeObject(JavaScriptHost.java:91)
        at com.google.gwt.core.client.impl.Impl.apply(Impl.java)
        at com.google.gwt.core.client.impl.Impl.entry0(Impl.java:214)
        at sun.reflect.GeneratedMethodAccessor151.invoke(Unknown Source)
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
        at java.lang.reflect.Method.invoke(Method.java:597)
        at com.google.gwt.dev.shell.MethodAdaptor.invoke(MethodAdaptor.java:103)
        at com.google.gwt.dev.shell.MethodDispatch.invoke(MethodDispatch.java:71)
        at com.google.gwt.dev.shell.OophmSessionHandler.invoke(OophmSessionHandler.java:167)
        at com.google.gwt.dev.shell.BrowserChannelServer.reactToMessages(BrowserChannelServer.java:281)
        at com.google.gwt.dev.shell.BrowserChannelServer.processConnection(BrowserChannelServer.java:531)
        at com.google.gwt.dev.shell.BrowserChannelServer.run(BrowserChannelServer.java:352)
        at java.lang.Thread.run(Thread.java:680)

    Leave a comment:


  • fatzopilot
    replied
    Hi jsres,

    thank you very much for sharing.
    I tested your code and it seems to work very well.

    Isomorphic, any chance of getting this into the main trunk?

    EDIT: Selecting the grouping granularity like "by day" or "by week" (works only for fields with supported data type) does not work any more using this solution

    Regards,
    fatzopilot
    Last edited by fatzopilot; 24 Aug 2011, 05:07.

    Leave a comment:


  • jsres
    replied
    I implemented menu-driven multiple group by in a ListGrid with the following override of a ListGrid method. I chose to override the default Grouping behavior from "reset the single group" to "add a level of grouping to the existing set of grouping fields."
    This, combined with the preexisting "ungroup" option, seems to allow the user arbitrary grouping ability, from the normal popup menu.

    Code:
    @Override  
    protected MenuItem[] getHeaderContextMenuItems(final Integer fieldNum) 
    {  
    	MenuItem newGroupBy = new MenuItem("Group by " + ListGridAdapter.this.getField(fieldNum).getTitle());  
    	newGroupBy.addClickHandler(new com.smartgwt.client.widgets.menu.events.ClickHandler() {  
    		public void onClick(MenuItemClickEvent event){
    			String[] existingGroupByFields = getGroupByFields();
    			String[] newGroupByFields = null;
    			if ( existingGroupByFields == null ) {
    				newGroupByFields = new String[]{ListGridAdapter.this.getFieldName(fieldNum)};
    			}
    			else {
    				newGroupByFields = new String[existingGroupByFields.length + 1];
    				for (int i = 0; i < existingGroupByFields.length; i++) {  
    					newGroupByFields[i] = existingGroupByFields[i];  
    				}
    				newGroupByFields[existingGroupByFields.length] = ListGridAdapter.this.getFieldName(fieldNum);
    			}
    			ListGridAdapter.this.ungroup();
    			setGroupStartOpen("all");
    			ListGridAdapter.this.groupBy(newGroupByFields);
    		}
    	});
    	
    	final MenuItem[] originalMenuItems = super.getHeaderContextMenuItems(fieldNum);  
    	MenuItem[] toReturn = new MenuItem[originalMenuItems.length];  
    	for (int i = 0; i < originalMenuItems.length; i++) {
    		String title = originalMenuItems[i].getTitle();
    		toReturn[i] = originalMenuItems[i];  
    		if ( title != null && title.startsWith("Group by") )
    		{
    			toReturn[i] = newGroupBy;
    		}
    	}
    	return toReturn;  
    } ;

    Leave a comment:


  • hardtail29
    replied
    No, I haven't gotten to it yet. There is another problem and that is when you group with multiple columns summary fields do not properly calculate for the top group. See thread http://forums.smartclient.com/showthread.php?t=17142

    Leave a comment:


  • kylemwhite
    replied
    hardtail29,

    Did you end up implementing this? If so, would you like to share some code or at least your ideas on what the UI looks like?

    Thanks.

    Leave a comment:


  • hardtail29
    replied
    Thanks, that is very helpful. I may not get to this added feature for several weeks but will let you know how I make out.

    Leave a comment:


  • Isomorphic
    replied
    You don't need any JavaScript - best not to think in terms of JavaScript at all when working with SmartGWT. Normal subclassing and extensions are all done via just Java. In this case, if you wanted to build this yourself, you'd override ListGrid.getHeaderContextMenuItems() and add your own menu items to do multi-level grouping.

    Your MenuItems could have submenus (Group By.. Then By..) or you might launch a dialog based on the Window class. Either way, the result should be a call to ListGrid.groupBy().

    Leave a comment:


  • hardtail29
    replied
    Multiple grouping is the only thing stopping me from using smartgwt for a current project. I know Java and Javascript but am new to the GWT framework and how I would add this feature to the existing library. Since the project has a short delivery time what is the effort for someone like me to implement?

    Since this is already supported in the java code I imagine it is to add it to the javascript library?

    Leave a comment:


  • Isomorphic
    replied
    There's no user interface for it yet. You could build your own by adding new menu items (eg "Grouping...") or it would be a valid Feature Sponsorship to have a default UI added to the framework.

    Leave a comment:


  • hardtail29
    replied
    Originally posted by sjivan
    Added ListGrid.setGroupByField(String... field) to SVN.

    Sanjiv
    I see ListGrid supports multiple grouping from java. What I am missing is how multiple grouping (sub-grouping) can be done from the user iface using the javascript drop-down. Everytime the user selects a grouping from the drop-down the current grouping (single or multiple) is lost.

    any hints?

    Leave a comment:


  • sjivan
    replied
    Added ListGrid.setGroupByField(String... field) to SVN.

    Sanjiv

    Leave a comment:


  • fatzopilot
    started a topic Group by multiple fields possible?

    Group by multiple fields possible?

    According to this thread
    http://forums.smartclient.com/showthread.php?t=2681&highlight=subgroup
    it seems grouping by multiple fields is supported in smartclient at least programmatically for quite a while.
    Is this also supported in smartGWT?
    The ListGrid's signature is just
    Code:
    ListGrid.setGroupByField(String field)
    so it seems it just supports one field to group by.

    Thanks
    fatzopilot
Working...
X