Announcement

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

    how to (easily) populate tree or treegrid from recordlist

    If we have a recordlist (or array of records) that have been retrieved by a manual call to fetchdata from a datasource object, is there an easy way to set a tree or treegrid to those records? (I didn't see any simple setdata method that would work, since the tree.setdata method expects a treenode array, not a recordlist.) I feel that there must be a simple method, since if I directly set a TreeGrid object to this datasource, everything gets automatlly populated, so I should be able to decouple the recordlist from the treegrid and then manually set the treeGrid to the recordlist. (In case you're curious as to why I'm doing this: I want to destroy the treegrid on occasion, but NOT destroy the underlying tree data; but, it seems that if/when I destroy the treegrid, the underlying tree (and data) get lost, if I'm not mistaken. If there were a way to "save" this underlying tree model, then that would be an even better solution....)

    Here's the code used to fetch the recordlist or array of records:

    Code:
    DataSource x = DataSource.get("dsIAFolderONLY");
    DSRequest requestProperties = new DSRequest();
    requestProperties.setOperationId("writableFolders");
    DSCallback xCallback = new DSCallback() {
    	
    	@Override
    	public void execute(DSResponse response, Object rawData, DSRequest request) {
    		 RecordList aa = response.getDataAsRecordList();
    	}
    };
    x.fetchData(null, xCallback, requestProperties );
    Full Infrastucture Details:
    ==================================
    SmartGWT Version: SC_SNAPSHOT-2011-12-05/PowerEdition Deployment (built 2011-12-05)

    OS: Windows XP Pro
    IDE: MyEclipse 10.0 with Google Plugin for Eclipse (2.5)
    Browser: Mozilla Firefox 4.0.1
    GWT SDK: 2.4.0
    Sun JDK 1.6.0_27

    #2
    Code:
    http://www.smartclient.com/smartgwt/javadoc/com/smartgwt/client/widgets/grid/ListGrid.html#setData%28com.smartgwt.client.data.RecordList%29
    This does not work?

    Comment


      #3
      I don't think that works. I get the error:

      Uncaught JavaScript exception [_3.data.isFolder is not a function] in http://127.0.0.1:8888/builtinds/sc/modules/ISC_Grids.js, line 3096

      Here's a quick test code I wrote:

      Code:
      DataSource x = DataSource.get("dsIAFolderONLY");
      DSRequest requestProperties = new DSRequest();
      requestProperties.setOperationId("writableFolders");
      DSCallback xCallback = new DSCallback() {
      
      	@Override
      	public void execute(DSResponse response, Object rawData, DSRequest request) {
      		RecordList aa = response.getDataAsRecordList();
      		TGFolderListNoDS zz = new TGFolderListNoDS();
      		zz.setData(aa);
      		 zz.setWidth(300);
      	       zz.setHeight("100%");
      	       hlSelectFilesFromTree.addChild(zz);
      	}
      };
      x.fetchData(null, xCallback, requestProperties );

      Comment

      Working...
      X