Announcement

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

    Refreshing data in TreeGrid doesn't show expansion icons (+ signs)

    Using the latest smartgwt (3.1)... sorry, but I couldn't get the developer console to load to tell me the exact version, but looking at the javascript I imagine it's

    isc.version="v8.3_2012-11-20/LGPL Development Only"

    I am creating a tree with a datasource whose data is supposed to come from a gwt rpc call. The records are set as PARENT modetype, since I want each open operation on each node to call the GWT rpc.

    When I first load the tree, all top level folder icons show appropriate '+' expansion signs, however, when I refresh the data, the '+' signs are gone.

    I've tried all kind of things to make it work and nothing does! Please help!

    Code follows

    Code:
    package testGWT.client;
    
    import java.util.ArrayList;
    import java.util.List;
    
    import com.google.gwt.event.dom.client.ClickEvent;
    import com.google.gwt.event.dom.client.ClickHandler;
    import com.google.gwt.user.client.ui.Button;
    import com.google.gwt.user.client.ui.FlowPanel;
    import com.google.gwt.user.client.ui.LayoutPanel;
    import com.smartgwt.client.data.Criteria;
    import com.smartgwt.client.data.DSRequest;
    import com.smartgwt.client.data.DSResponse;
    import com.smartgwt.client.data.DataSource;
    import com.smartgwt.client.data.Record;
    import com.smartgwt.client.data.fields.DataSourceTextField;
    import com.smartgwt.client.types.DSDataFormat;
    import com.smartgwt.client.types.DSProtocol;
    import com.smartgwt.client.widgets.tree.TreeGrid;
    import com.smartgwt.client.widgets.tree.TreeGridField;
    import com.smartgwt.client.widgets.tree.TreeNode;
    
    public class SmartGWTTest extends LayoutPanel {
    	public class ParentThing {
    		public final String name;
    		public final String primaryKey;
    
    		public ParentThing(String primaryKey, String name) {
    			super();
    			this.primaryKey = primaryKey;
    			this.name = name;
    		}
    	}
    
    	public class MyDataSource extends DataSource {
    		public MyDataSource() {
    			setDataProtocol(DSProtocol.CLIENTCUSTOM);
    			setDataFormat(DSDataFormat.CUSTOM);
    			setClientOnly(false);
    			DataSourceTextField primaryKey = new DataSourceTextField("primaryKey");
    			primaryKey.setPrimaryKey(true);
    
    			DataSourceTextField parentId = new DataSourceTextField("parentId");
    			parentId.setForeignKey("primaryKey");
    
    			DataSourceTextField nameField = new DataSourceTextField("nameField");
    
    			addField(primaryKey);
    			addField(parentId);
    			addField(nameField);
    		}
    
    		@Override
    		protected Object transformRequest(DSRequest request) {
    			String requestId = request.getRequestId();
    			DSResponse response = new DSResponse();
    
    			switch (request.getOperationType()) {
    			case FETCH:
    				executeFetch(requestId, request, response);
    				break;
    			default:
    				throw new RuntimeException("Operation " + request.getOperationType() + " not yet permitted");
    			}
    			return request.getData();
    		}
    
    		void executeFetch(final String requestId, final DSRequest request, final DSResponse response) {
    			Criteria criteria = request.getCriteria();
    
    			final String parentId = criteria.getAttribute("parentId");
    			if (parentId != null && !"".equals(parentId)) {
    				// TODO: Retrieve children here
    				processResponse(requestId, response);
    			} else {
    
    				String searchCriteria = criteria.getAttribute("searchCriteria");
    				if (searchCriteria == null) {
    					searchCriteria = "0";
    
    				}
    
    				if (searchCriteria != null) {
    					// Fill in the top level
    					List<ParentThing> data = new ArrayList<ParentThing>();
    					for (int i = 0; i <= 5; ++i) {
    						ParentThing parentThing = new ParentThing("pk" + i, "name " + i);
    						data.add(parentThing);
    					}
    					Record[] records = new Record[data.size()];
    					int i = 0;
    					for (ParentThing parentThing : data) {
    						String primaryKey = parentThing.primaryKey;
    						TreeNode record = new TreeNode(primaryKey);
    						records[i] = record;
    						record.setAttribute("nameField", searchCriteria + parentThing.name);
    						record.setAttribute("primaryKey", searchCriteria + primaryKey);
    						record.setAttribute("parentId", (String) null);
    						++i;
    					}
    					response.setData(records);
    				}
    
    				processResponse(requestId, response);
    			}
    		}
    	}
    
    	int callCount = 0;
    	private TreeGrid treeGrid;
    
    	public SmartGWTTest() {
    		FlowPanel mainPanel = new FlowPanel();
    		setHeight("100%");
    		setWidth("100%");
    
    		treeGrid = new TreeGrid();
    		treeGrid.setLoadDataOnDemand(true);
    		final MyDataSource dataSource = new MyDataSource();
    		treeGrid.setDataSource(dataSource);
    		treeGrid.setAutoFetchData(true);
    
    		treeGrid.setFields(new TreeGridField("nameField", "Name"));
    		treeGrid.setWidth100();
    		treeGrid.setHeight100();
    
    		treeGrid.draw();
    
    		Button btn = new Button("Click me to refresh");
    		btn.addClickHandler(new ClickHandler() {
    			@Override
    			public void onClick(ClickEvent event) {
    				Criteria criteria = new Criteria();
    				criteria.setAttribute("searchCriteria", ++callCount);
    				treeGrid.fetchData(criteria);
    			}
    		});
    		mainPanel.add(btn);
    		mainPanel.add(treeGrid);
    		add(mainPanel);
    	}
    
    }
    Last edited by rleibman; 7 May 2013, 10:54.

    #2
    Additional information (not missing)

    Justin Baker seems to be under the impression that I'm not providing enough information in this message to replicate the issue. That may be because in my preface to posting the code I wrote the context for where this is going.

    However, the code is mostly self contained (minus boilerplate stuff like html & xml).

    If you're missing anything to be able to reproduce it please let me know.

    Comment


      #3
      ok... giving up...

      OK, So I'm giving up, aside from this issue, which nobody seemed to be able to help with, I just can't seem to get a break in using smartGWT.
      1 - I use chrome, smartGWT doesn't like chrome (at least not for debugging)
      2 - I use GWT Designer, smartGWT doesn't play with the GWT designer
      3 - I have 4 man-years of already written code in GWT.
      4 - SmartGWT doesn't work nicely with GWT-RPC
      5 - SmartGWT doesn't work nicely embedded in GWT panel.
      6 - SmartGWT doesn't work nicely with GWT popups of existing application (they pop-behind).

      I really needed a tree grid, but for the hassle that is worth, I'm just going to use a plain old GWT DataGrid.

      Comment


        #4
        What you've experienced is mostly a bunch of issues with GWT rather than with SmartGWT as such:

        1. Chrome is broken for GWT in general, not SmartGWT. This is due to a bug in Chrome (see FAQ). You may have lucked out and not been affected by this bug, but we've seen a number of mentions that the core GWT team doesn't use it, partly because this same bug makes Chrome really slow for GWT development mode (note SuperDevMode gets around this).

        4. While we very strongly recommend against GWT-RPC because it's just worse than alternatives, we "play nicely" with it; a bunch of people are using it and we created a feature (dataProtocol:clientCustom) almost solely to enable clean integration.

        However, note that GWT-RPC is no longer considered the right away to do data binding even for core GWT, so your code is considered a legacy approach by either framework. In core GWT you are supposed to be moving on to the successor RequestFactory; of course there are many, many core GWT issues with RequestFactory at the moment.

        5. Did you discover a bug here? We haven't had any reports of a bug of this kind in a while.

        6. You just need to set the zIndex of your GWT pop-ups very high (over 200,000). As covered in the FAQ, there's no way we can really coordinate with core GWT on zIndex usage, so this is necessarily manual.

        However, that all said, if all you want is just a TreeGrid, and you have a bunch of legacy code, and you aren't planning to migrate wholly to SmartGWT in the future, we can't recommend embedding SmartGWT *just for a TreeGrid* if the TreeGrid features you need are straightforward to replicate with DataGrid.

        It *would* make sense to invest the effort to get it right if you had longer term plans to upgrade to SmartGWT, or if you were doing something like an editable grid with frozen columns, inline filtering and autofit - that kind of thing is multiple man-years to replicate in plain GWT.

        Comment


          #5
          You still have not addressed the issue in the original message!

          Comment


            #6
            It's queued to be looked at.

            We address bugs based on severity / people affected, and supported customers come first.

            Comment


              #7
              Please give the latest nightly build a try. We're not reproducing the problem with your sample code at this time. If you continue to see it, please let us know (along with the exact version you're testing against)

              Thanks
              Isomorphic Software

              Comment

              Working...
              X