Announcement

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

    Treegrid not working as expected

    Hello there,

    I am using SmartClient Version: v10.0p_2015-07-08/PowerEdition Deployment (built 2015-07-08) with FF26.

    I am trying to populate a Treegrid with data from two datasource which have FK relationship. But for some reason I am not able to display the tree. I have also attached the screenshot of the parent-child.

    cheers
    Zolf

    Code:
    DataSource ds = DataSource.get("distributorProductDS");		
    		Tree distributorTree = new Tree();  
            distributorTree.setModelType(TreeModelType.PARENT);  
            distributorTree.setRootValue(1);  
            distributorTree.setNameProperty("name");  
            distributorTree.setIdField("id");  
            distributorTree.setParentIdField("mfk");  
            distributorTree.setShowRoot(true); 
            //employeeTree1.setOpenProperty("isOpen");  
    		
            final DistributorTreeGrid treeGrid = new DistributorTreeGrid(); 
            treeGrid.setDragDataAction(DragDataAction.MOVE);  
            treeGrid.setDataProperties(distributorTree);
            treeGrid.setDataSource(ds);
            treeGrid.setAlwaysShowOpener(false);
            treeGrid.addDrawHandler(new DrawHandler() {  
                public void onDraw(DrawEvent event) {  
                    treeGrid.fetchData();  
                }  
            });
    Code:
    <DataSource ID="distributorProductDS" serverType="sql" tableName="expd">
    	<fields>
    		<field name="id" type="sequence" hidden="true" primaryKey="true" />
    		<field name="name" title="Product Name" type="ntext" />
    		<field name="mfk" title="ecid" foreignKey="distributorDS.id" type="integer" joinType="outer" displayField = "didi"
    			required="true"/>
    		<field name="didi" includeFrom="distributorDS.name" hidden="true" />
    	</fields>
    </DataSource>
    Code:
    public class DistributorTreeGrid extends TreeGrid
    {
    	public DistributorTreeGrid()
    	{
    		setWidth(300);
    		setHeight100();
    		setShowEdges(true);
    		setBorder("0px");
    		setBodyStyleName("normal");
    		setShowHeader(false);
    		setLeaveScrollbarGap(false);
    		setEmptyMessage("<br>Drag & drop parts here");
    		setManyItemsImage("cubes_all.png");
    		setAppImgDir("pieces/16/");
    		setCanReorderRecords(true);
    		setCanAcceptDroppedRecords(true);
    		setCanDragRecordsOut(true);
    	}
    }
    Below is my Server logs

    === 2015-07-21 13:45:14,596 [2-24] DEBUG ISCKeyedObjectPool - Borrowing object for 'distributorProductDS'
    === 2015-07-21 13:45:14,596 [2-24] DEBUG PoolableDataSourceFactory - Activated DataSource 61 of type 'distributorProductDS'
    === 2015-07-21 13:45:14,596 [2-24] DEBUG DSRequest - Caching instance 61 of DS 'distributorProductDS' from DSRequest.getDataSource()
    === 2015-07-21 13:45:14,596 [2-24] DEBUG DSRequest - Caching instance 61 of DS distributorProductDS
    === 2015-07-21 13:45:14,597 [2-24] DEBUG RPCManager - Request #1 (DSRequest) payload: {
    criteria:{
    mfk:1
    },
    operationConfig:{
    dataSource:"distributorProductDS",
    repo:null,
    operationType:"fetch",
    textMatchStyle:"exact"
    },
    componentId:"isc_DistributorTreeGrid_0",
    appID:"builtinApplication",
    operation:"distributorProductDS_fetch",
    oldValues:{
    mfk:1
    },
    progressiveLoading:false,
    resultTreeIdField:"id",
    resultTreeParentIdField:"mfk"
    }
    === 2015-07-21 13:45:14,597 [2-24] INFO IDACall - Performing 1 operation(s)
    === 2015-07-21 13:45:14,597 [2-24] DEBUG ISCKeyedObjectPool - Borrowing object for 'distributorDS'
    === 2015-07-21 13:45:14,597 [2-24] DEBUG PoolableDataSourceFactory - Activated DataSource 21 of type 'distributorDS'
    === 2015-07-21 13:45:14,597 [2-24] DEBUG Relation - Caching instance of toDS 'distributorDS' in the DSRequest map
    === 2015-07-21 13:45:14,597 [2-24] DEBUG DeclarativeSecurity - Processing security checks for DataSource null, field null
    === 2015-07-21 13:45:14,597 [2-24] DEBUG DeclarativeSecurity - DataSource distributorProductDS is not in the pre-checked list, processing...
    === 2015-07-21 13:45:14,597 [2-24] DEBUG DeclarativeSecurity - Processing security checks for DataSource distributorDS, field id
    === 2015-07-21 13:45:14,597 [2-24] DEBUG DeclarativeSecurity - DataSource distributorDS is not in the pre-checked list, processing...
    === 2015-07-21 13:45:14,598 [2-24] DEBUG DeclarativeSecurity - Processing security checks for DataSource distributorDS, field name
    === 2015-07-21 13:45:14,598 [2-24] DEBUG DeclarativeSecurity - DataSource distributorDS is not in the pre-checked list, processing...
    === 2015-07-21 13:45:14,598 [2-24] DEBUG AppBase - [builtinApplication.distributorProductDS_fetch] No userTypes defined, allowing anyone access to all operations for this application
    === 2015-07-21 13:45:14,598 [2-24] DEBUG AppBase - [builtinApplication.distributorProductDS_fetch] No public zero-argument method named '_distributorProductDS_fetch' found, performing generic datasour
    ce operation
    === 2015-07-21 13:45:14,598 [2-24] INFO SQLDataSource - [builtinApplication.distributorProductDS_fetch] Performing fetch operation with
    criteria: {mfk:1} values: {mfk:1}
    === 2015-07-21 13:45:14,600 [2-24] INFO SQLDataSource - [builtinApplication.distributorProductDS_fetch] derived query: SELECT $defaultSelectClause FROM $defaultTableClause$defaultAnsiJoinClause WHERE
    $defaultWhereClause
    === 2015-07-21 13:45:14,600 [2-24] INFO SQLDataSource - [builtinApplication.distributorProductDS_fetch] 61: Executing SQL query on 'SQLServer': SELECT expd.id, expd.name, expd.mfk, dtor.name AS didi
    FROM expd LEFT OUTER JOIN dtor ON expd.mfk = dtor.id WHERE (expd.mfk=1)
    === 2015-07-21 13:45:14,600 [2-24] DEBUG SQLConnectionManager - [builtinApplication.distributorProductDS_fetch] Borrowed connection '20627506'
    === 2015-07-21 13:45:14,600 [2-24] DEBUG SQLDriver - [builtinApplication.distributorProductDS_fetch] About to execute SQL query in 'SQLServer' using connection '20627506'
    === 2015-07-21 13:45:14,600 [2-24] INFO SQLDriver - [builtinApplication.distributorProductDS_fetch] Executing SQL query on 'SQLServer': SELECT expd.id, expd.name, expd.mfk, dtor.name AS didi FROM exp
    d LEFT OUTER JOIN dtor ON expd.mfk = dtor.id WHERE (expd.mfk=1)
    === 2015-07-21 13:45:14,602 [2-27] DEBUG XML - Parsed XML from (in memory stream): 18ms
    === 2015-07-21 13:45:14,602 [2-27] DEBUG ISCKeyedObjectPool - Borrowing object for 'transaction'
    === 2015-07-21 13:45:14,602 [2-27] DEBUG PoolableDataSourceFactory - Created DataSource null of type 'transaction' in the pooling flow
    === 2015-07-21 13:45:14,602 [2-27] DEBUG ISCKeyedObjectPool - Borrowing object for 'Object'
    === 2015-07-21 13:45:14,603 [2-27] DEBUG PoolableDataSourceFactory - Created DataSource 78 of type 'Object' and assigned it to thread qtp31122332-27
    === 2015-07-21 13:45:14,603 [2-27] DEBUG PoolableDataSourceFactory - Created DataSource 78 of type 'Object' in the pooling flow
    === 2015-07-21 13:45:14,603 [2-27] DEBUG PoolableDataSourceFactory - Activated DataSource 78 of type 'Object'
    === 2015-07-21 13:45:14,603 [2-27] DEBUG ISCKeyedObjectPool - Borrowing object for 'List'
    === 2015-07-21 13:45:14,603 [2-27] DEBUG PoolableDataSourceFactory - Created DataSource 79 of type 'List' and assigned it to thread qtp31122332-27
    === 2015-07-21 13:45:14,603 [2-27] DEBUG PoolableDataSourceFactory - Created DataSource 79 of type 'List' in the pooling flow
    === 2015-07-21 13:45:14,603 [2-27] DEBUG PoolableDataSourceFactory - Activated DataSource 79 of type 'List'
    === 2015-07-21 13:45:14,603 [2-27] DEBUG ISCKeyedObjectPool - Borrowing object for 'elem'
    === 2015-07-21 13:45:14,603 [2-27] DEBUG PoolableDataSourceFactory - Created DataSource null of type 'elem' in the pooling flow
    === 2015-07-21 13:45:14,603 [2-27] DEBUG RPCManager - Processing 1 requests.
    Attached Files

    #2
    It's not clear what you're expecting to happen here - are you expecting the tree to magically pull records from multiple DataSources into a tree? It doesn't work that way, in fact, the Tree Data Binding overview explains what to do if you want records from multiple DataSources in one tree.

    Comment


      #3
      Hello Isomorphic,

      First,I dont believe in magic's(that is childish) and second I have referred to that Tree Binding overview and managed to get till here!!

      Now, what i am expecting is to have a treegrid with parent-child relation. The relationship I have created in my datasource distributorProductDS. Then I have told the Tree the parentID and the id(child). like so,

      Code:
      distributorTree.setNameProperty("name");  
      distributorTree.setIdField("id");  
      distributorTree.setParentIdField("mfk");
      and then referring to that returned data from the database via DS, I am expecting to have a tree structure(see attachment).

      -EFG
      fasdfas
      gfgfg
      hghg
      erer
      ewww
      hhh
      hmnf
      jyttr
      -XYZ
      uyiyu
      oouy
      jhj
      kfsfjnxggf
      gagbnbdgh

      Hope it is clear now and I will appreciate to have a mature discussion.

      cheers
      Zolf
      Attached Files

      Comment


        #4
        You've posted only one DataSource ("distributorProductDS") which has a foreignKey to another DataSource ("distributorDS") which you haven't shown.

        Again, if you are expecting the TreeGrid to form a tree out of the combination of records of the two DataSources, this is not documented anywhere and won't happen (hence the quip about "magic").

        However, if you read (or re-read) the Tree Data Binding guide, starting around the sentence:

        If you have a tree where there is no convenient unique ID, for example, you have mixed types of nodes (for example, departments and employees), use one of the following approaches: ...
        .. then you'll find an explanation of how you can take any kind of data - resulting from two or more database tables, or from other sources - and still deliver it to the TreeGrid. We referred you to this last time too - what may help is to look at this example from the wiki.
        Last edited by Isomorphic; 22 Jul 2015, 00:04. Reason: Fixed link

        Comment


          #5
          Hello Isomorphic,

          Thanks for your feedback. That link for the example is not working.Can you please send me the correct link. Below I have copied the DataSource distributorDS.

          Code:
          <DataSource ID="distributorDS" serverType="sql" tableName="dtor">
          	<fields>
          		<field name="id" type="sequence" hidden="true" primaryKey="true" />
          		<field name="name" title="Description" type="ntext" required="true"/>
          		<field name="status" title="Status" type="boolean" />
          	</fields>
          </DataSource>
          If you have a dataset that is "parent-linked", that is, every node has a unique ID (the idField) and also has a property with the unique ID of it's parent node (the parentIdField) the tree can load child nodes by simply sending a DSRequest with appropriate Criteria. Given a parent node with ID "225" in a tree where the parentIdField is called "parentId", the criteria would be:

          { parentId : 225 }

          The client is asking the server: "give me all nodes whose parentId is 225", which are the children of node 225.
          what I understand is that I define the parentID and the idField and then I was expecting SGWT to load the parentID and below it its child based on the returned data from that DataSource.This what I understood from the doc of TreeDataBinding.
          the Child IDs are all unique.

          Please bear with me and guide me.

          cheers
          Zolf

          Comment


            #6
            Try this one... http://wiki.smartclient.com/pages/vi...pageId=4161546
            Last edited by Isomorphic; 22 Jul 2015, 00:04.

            Comment


              #7
              what I understand is that I define the parentID and the idField and then I was expecting SGWT to load the parentID and below it its child based on the returned data from that DataSource.
              This part is true.. but only within a single DataSource, not with more than one.

              Again take a look at the sample on the wiki, which shows a single DataSource that binds to a TreeGrid, while fetching and transforming data from two other DataSources.

              Comment

              Working...
              X