Announcement

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

    Tree setDefaultIsFolder() not work

    Hello,

    we're using:
    - SmartClient Version: SC_SNAPSHOT-2012-01-16_v8.2p/LGPL Development Only (built 2012-01-16)
    - firefox 9.0.1
    and it looks like that tree.setDefaultIsFolder(false) is not work.
    When datasource is changed, node is still added like parent and only after refresh is displayed like child.
    It works only if we add property some setChildrenProperty e.g tree.setChildrenProperty("isChildren");
    Thanx..

    Code:
    Code:
     
    protected TreeGrid createProjectTree() {
    		projectTree = new TreeGrid();
    		final Tree tree = new Tree();
    		tree.setModelType(TreeModelType.PARENT);
    		tree.setDefaultIsFolder(false);
    		tree.setNameProperty(CampaignProjectDescriptor.NAME);
    		tree.setIdField(CampaignProjectDescriptor.ID);
    		tree.setParentIdField(CampaignProjectDescriptor.PARENT + "." + CampaignProjectDescriptor.ID);
    		tree.setChildrenProperty("isChildren");
    		projectTree.setDataProperties(tree);
    		projectTree.setWidth(300);
    		projectTree.setShowAllRecords(true);
    		projectTree.setAutoFetchTextMatchStyle(TextMatchStyle.STARTS_WITH);
    		projectTree.setLoadDataOnDemand(false);
    		projectTree.addFetchDataHandler(new FetchDataHandler() {
    
    			@Override
    			public void onFilterData(FetchDataEvent event) {
    				DSRequest requestProperties = event.getRequestProperties();
    				requestProperties.setAttribute (set some atributes );
    			}
    		});
    
    		DomainClassDataSource dataSource = dataSourceFactory.getDataSource(CampaignProjectDescriptor.CLASS_NAME);
    		dataSource.getField(tree.getParentIdField()).setForeignKey(CampaignProjectDescriptor.ID);
    		projectTree.setDataSource(dataSource);
    		TreeGridField treeGridField = new TreeGridField(CampaignProjectDescriptor.NAME, MSG.messages.name());
    		treeGridField.setCanFilter(true);
    		treeGridField.setFilterOperator(OperatorId.ICONTAINS);
    
    		projectTree.setFields(treeGridField);
    		projectTree.setAutoFetchData(true);
    		projectTree.setShowFilterEditor(true);
    
    		projectTree.setHeaderAutoFitEvent(AutoFitEvent.NONE);
    		projectTree.setCanAutoFitFields(false);
    		projectTree.setCanResizeFields(false);
    
    		return projectTree;
    	}

    #2
    Our tests show defaultIsFolder working fine and the code you posted is not even close to being runnable. If you think there's a framework bug here, could you post a runnable test case (ideally based on a product sample) and make it clear what you were expecting the setting to do?

    Comment


      #3
      defaultIsFolder doesn't work for me

      if i load the app the children that are leafs and not folders are displayed well - as leafs

      after reparent all leafs became folders, despite i set the defaultIsFolder to false.

      after refresh of the app the leafs are displayed correctly.

      here is the json i fetch from server:
      [{"id":"a","ReportsTo":"root","isFolder":"true","isOpen":"true"},{"id":"b","ReportsTo":"a","isFolder":"false", "isOpen":"false"},{"id":"c","ReportsTo":"root","isFolder":"true","isOpen":"false"},{"id":"d","ReportsTo":"c","isFolder":"false","isOpen":"false"}]

      as you can see there are two folders and two leafs. but after reparenting all are displayed as folders.
      here is my code:

      public class FavoritesGrid extends TreeGrid {

      public FavoritesGrid() {
      setWidth("12%");
      setShowConnectors(false);
      setShowResizeBar(true);
      setCanReorderRecords(true);
      setCanAcceptDroppedRecords(true);
      setCanDragRecordsOut(true);
      setCanReparentNodes(true);
      setDragDataAction(DragDataAction.MOVE);
      setAutoSaveEdits(false);
      setAutoFetchData(false);
      setLoadDataOnDemand(false);

      setHeight("50%");

      RestDataSource ds = new RestDataSource();
      ds.setRecordXPath("/");
      ds.setDataFormat(DSDataFormat.JSON);

      OperationBinding fetch = new OperationBinding();
      fetch.setOperationType(DSOperationType.FETCH);
      fetch.setDataProtocol(DSProtocol.POSTMESSAGE);
      fetch.setDataFormat(DSDataFormat.JSON);

      OperationBinding add = new OperationBinding();
      add.setOperationType(DSOperationType.ADD);
      add.setDataProtocol(DSProtocol.POSTMESSAGE);
      add.setDataFormat(DSDataFormat.JSON);

      OperationBinding update = new OperationBinding();
      update.setOperationType(DSOperationType.UPDATE);
      update.setDataProtocol(DSProtocol.POSTMESSAGE);
      update.setDataFormat(DSDataFormat.JSON);

      ds.setOperationBindings(fetch, update, add);

      ds.setDataURL("/XY/Favorites");

      DataSourceTextField key = new DataSourceTextField("id", "id");
      key.setPrimaryKey(true);
      key.setRequired(true);
      DataSourceTextField parent = new DataSourceTextField("ReportsTo",
      "ReportsTo");
      parent.setRequired(true);
      parent.setForeignKey("id");
      parent.setRootValue("root");

      ds.setFields(key, parent);

      Tree tree = new Tree();
      tree.setDefaultIsFolder(false);
      tree.setRootValue("root");
      tree.setNameProperty("id");
      tree.setIdField("id");
      tree.setParentIdField("ReportsTo");
      tree.setOpenProperty("isOpen");
      tree.setIsFolderProperty("isFolder");

      setDataProperties(tree);

      setDataSource(ds);

      fetchData();
      }
      }


      Be sure your post includes:

      1. v8.1p_2012-06-12/LGPL Development Only (built 2012-06-12)

      2. firefox 14.0.1

      Comment

      Working...
      X