Announcement

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

    Tree setIsFolderProperty method does not work

    Hi,
    i use Smartgwt 3.0. Im working on a Tree that shows directory structure. As i know, which node is Folder and which is not i wanted to reduce the requests by setting setIsFolderProperty. This unfortunately doesnt work for me. I've also changed the property defaultIsFolder but also no change. This is how im using it:
    Code:
    private static class FilePickerWindow extends Window {
    		private static final RestDataSource directoryDataSource;
    
    		static {
    			directoryDataSource = new RestDataSource();
    			directoryDataSource.setID("directoryBrowserDataSource");
    			directoryDataSource.setDropExtraFields(false);
    			directoryDataSource.setDropUnknownCriteria(false);
    			directoryDataSource.setDataProtocol(DSProtocol.GETPARAMS);
    			directoryDataSource.setDataFormat(DSDataFormat.JSON);
    			DataSourceField name = new DataSourceTextField("name");
    			DataSourceField parent = new DataSourceTextField("parent");
    			DataSourceField path = new DataSourceTextField("path");
    			DataSourceField directory = new DataSourceBooleanField("dir");
    			parent.setForeignKey("path");
    			path.setPrimaryKey(true);
    			directoryDataSource.setFields(name, parent, path, directory);
    			directoryDataSource.setDataURL(GWT.getHostPageBaseURL() + "directoryBrowser");
    		}
    
    		private String openingNodeId;
    
    		private FilePickerWindow() {
    			Tree tree = new Tree();
    			tree.setModelType(TreeModelType.CHILDREN);
    			tree.setIdField("name");
    			tree.setNameProperty("name");
    			tree.setIsFolderProperty("dir");
    			tree.setDefaultIsFolder(false);
    			final TreeGrid treeGrid = new TreeGrid();
    			treeGrid.setData(tree);
    			treeGrid.setDataSource(directoryDataSource);
    			treeGrid.setLoadDataOnDemand(true);
    			treeGrid.setKeepParentsOnFilter(true);
    			treeGrid.setFields(new TreeGridField("name"), new TreeGridField("path"), new TreeGridField("dir"));
    			treeGrid.setAutoFetchData(true);
    			addItem(treeGrid);
    			setWidth(300);
    			setHeight(400);
    			setCanDragResize(true);
    		}
    	}
    Im sendig data from server in format: {"response":{"size":1,"data":[{"name":"tmp","path":"/tmp","dir":true}]}}

    In the TreeGrid i can see the dir property but every node is displayed as a Folder.

    Thanks in advance.

    #2
    Looks like you're customizing a tree then applying it via 'setData()'.
    This denotes the client-side tree of data to display and would have no effect on the data retrieved when you then actually perform a fetch.
    Instead you'd want to use 'setDataProperties()' - this acts as a template set of properties applied to the special dataSource-aware tree that gets generated when the fetch completes.

    Let us know if you still have problems with it after switching to that API.

    Comment


      #3
      Thanks, that did the trick. But now im trying to set setSortFoldersBeforeLeaves(true);

      I've tried it both on tree and treeGrid but it does not work. The directories are not listed as first. What could be the problem?

      Thank you in advance

      Comment


        #4
        Have you set separateFolders?

        Comment

        Working...
        X