Announcement

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

    TreeGrid setFetchOperation

    Hi Isomorphic,

    Can you please provide me some guidance on controlling the fetch operation id used when expanding a folder?

    Setting the fetch operation doesn't appear to change what SmartGWT uses.

    Even though I set the fetchOperation on the TreeGrid, the default openFolder handler uses the default fetch operation.

    Code:
    {
        dataSource:"task", 
        operationType:"fetch", 
        data:{
            parentId:"b45ade654838491a8c8ac62da3b3460d:d335e0aaf61f409ea4673d3997250d51:2"
        }, 
    ...
    }
    I don't see the fetch using the specified operationId.

    SmartClient Version: v10.1p_2017-08-10/Pro Deployment (built 2017-08-10)

    Thanks

    #2
    You need to use TreeGrid.fetchOperation to set the operationId. If you need further assistance, you'll need to provide a complete repro case, as the FAQ instructs, perhaps by modifying one of our Feature Explorer samples.

    Comment


      #3
      Hi Isomorphic,

      As noted above, "...even though I set the fetchOperation on the TreeGrid...", it doesn't seem to use that for framework initiated fetches, for example, when a folder is opened. The operationType is fetch, and the operationId is never included.

      To be clear, I use com.smartgwt.client.widgets.grid.ListGrid.setFetchOperation(String) to set our operationId. The implementation of that method is on the ListGrid class, I don't see any override on the TreeGrid.

      Regards

      Comment


        #4
        Hi Isomorphic,

        Run the following sample module, click on the + icon next to one of the folders, and you will see the initiated fetch by the framework is not honouring the operationId which was set by treeGrid.setFetchOperation("fetchMe").

        Regards

        -----

        EntryPoint

        Code:
        package com.sandbox.client;
        
        import java.util.ArrayList;
        import java.util.List;
        
        import com.google.gwt.core.client.EntryPoint;
        import com.smartgwt.client.data.DataSource;
        import com.smartgwt.client.types.AutoFitWidthApproach;
        import com.smartgwt.client.types.FetchMode;
        import com.smartgwt.client.types.SelectionStyle;
        import com.smartgwt.client.widgets.tree.ResultTree;
        import com.smartgwt.client.widgets.tree.TreeGrid;
        import com.smartgwt.client.widgets.tree.TreeGridField;
        import com.smartgwt.client.widgets.tree.TreeNode;
        
        public class Sandbox10 implements EntryPoint {
        
            @Override
            public void onModuleLoad() {
        
                TreeGrid treeGrid = new TreeGrid();
                treeGrid.setDataSource(DataSource.get("sandbox10"));
                treeGrid.setFetchOperation("fetchMe");
                treeGrid.setTitle("Sandbox10");
                treeGrid.setWidth100();
                treeGrid.setHeight100();
                treeGrid.setAutoFitFieldsFillViewport(Boolean.TRUE);
                treeGrid.setAutoFitWidthApproach(AutoFitWidthApproach.BOTH);
                treeGrid.setAutoFitFieldWidths(Boolean.TRUE);
                treeGrid.setCanAutoFitFields(Boolean.TRUE);
                treeGrid.setShowRollOver(Boolean.FALSE);
                treeGrid.setAlternateRecordStyles(Boolean.TRUE);
                treeGrid.setSelectionType(SelectionStyle.NONE);
                treeGrid.setLoadDataOnDemand(Boolean.TRUE);
                treeGrid.setDataFetchMode(FetchMode.BASIC);
                treeGrid.setAutoFetchData(Boolean.FALSE);
        
                TreeGridField nameField = new TreeGridField("name");
                TreeGridField idField = new TreeGridField("id");
                TreeGridField parentIdField = new TreeGridField("parentId");
                TreeGridField openField = new TreeGridField("isOpen");
                openField.setHidden(Boolean.TRUE);
                TreeGridField folderField = new TreeGridField("isFolder");
                folderField.setHidden(Boolean.TRUE);
        
                ResultTree properties = new ResultTree();
                properties.setDefaultIsFolder(Boolean.FALSE);
                properties.setDisableCacheSync(Boolean.TRUE);
                properties.setOpenProperty("isOpen");
                treeGrid.setDataProperties(properties);
        
                treeGrid.setDefaultFields(nameField, idField, parentIdField, openField, folderField);
        
                List<TreeNode> nodeList = new ArrayList<TreeNode>();
                nodeList.add(createNode("WF_0", "0", null, true, true));
                nodeList.add(createNode("Child_WF_1", "1", "0", false, true));
                nodeList.add(createNode("Child_WF_2", "2", "0", false, true));
                nodeList.add(createNode("Child_3", "3", "0", false, false));
                nodeList.add(createNode("Child_4", "4", "0", false, false));
        
                treeGrid.setInitialData(nodeList.toArray(new TreeNode[nodeList.size()]));
                treeGrid.show();
            }
        
            private static TreeNode createNode(String name, String id, String parentId, boolean isOpen, boolean isFolder) {
                TreeNode node = new TreeNode();
                node.setAttribute("name", id);
                node.setAttribute("id", id);
                if (parentId != null) node.setAttribute("parentId", parentId);
                if (isOpen) node.setAttribute("isOpen", isOpen);
                if (isFolder) node.setAttribute("isFolder", isFolder);
                return node;
            }
        }

        sandbox10.ds.xml

        Code:
        <?xml version="1.0" encoding="UTF-8" standalone="yes"?>
        <DataSource xmlns:fmt="WEB-INF/" ID="sandbox10" serverType="generic">
            <titleField>name</titleField>
            <fields>
                <field name="id" type="text" primaryKey="true" canEdit="false">
                    <title>Id</title>
                </field>
                <field name="parentId" typ="text" foreignKey="sandbox10.id" canEdit="false">
                    <title>Parent Id</title>
                </field>
                <field name="name" type="text" canEdit="false">
                    <title>Name</title>
                </field>
                <field name="isFolder" type="boolean" canEdit="false">
                    <title>Folder</title>
                </field>
                <field name="isOpen" type="boolean" canEdit="false">
                    <title>Open</title>
                </field>
            </fields>
            <serverObject lookupStyle="new" className="com.sandbox.server.Sandbox10DS"/>
            <operationBindings>
                <binding operationType="fetch" operationId="fetchMe" serverMethod="fetchMe" />
            </operationBindings>
        </DataSource>
        Server DS Object

        Code:
        package com.sandbox.server;
        
        import com.isomorphic.datasource.DSRequest;
        import com.isomorphic.datasource.DSResponse;
        
        public class Sandbox10DS {
        
            public Sandbox10DS() {}
        
            public DSResponse fetch(final DSRequest req) {
                throw new RuntimeException("fetch method called.");
            }
        
            public DSResponse fetchMe(final DSRequest req) {
                throw new RuntimeException("fetchMe method called.");
            }
        }

        Open Folder Fetch
        Code:
        {
            dataSource:"sandbox10",
            operationType:"fetch",
            data:{
                parentId:"2"
            },
            textMatchStyle:"exact",
            resultTree:[ResultTree ID:isc_ResultTree_1 (dataSource: sandbox10, created by: isc_TreeGrid_0)],
            callback:{
                caller:[ResultTree ID:isc_ResultTree_1 (dataSource: sandbox10, created by: isc_TreeGrid_0)],
                methodName:"loadChildrenReply"
            },
            willHandleError:true,
            showPrompt:true,
            oldValues:{
                parentId:"2"
            },
            requestId:"sandbox10$6270",
            internalClientContext:{
                parentNode:{
                    name:"2",
                    id:"2",
                    parentId:"0",
                    isFolder:true,
                    isOpen:true,
                    children:Array[0]
                },
                relationship:{
                    childDS:[DataSource ID:sandbox10],
                    parentDS:[DataSource ID:sandbox10],
                    parentIdField:"parentId",
                    idField:"id"
                },
                childrenReplyCallback:{
                },
                fetchCount:1
            },
            fallbackToEval:false,
            progressiveLoading:false,
            lastClientEventThreadCode:"MUP9",
            bypassCache:true,
            dataProtocol:"getParams"
        }

        Comment


          #5
          We've fixed the issue for SGWT 6.0p/SC 11.0p and newer releases, and the fix will be in the nightly builds dated 2017-12-06 and beyond.

          We plan to address it in SGWT 5.1p/SC 10.1p as well, but as is often the case, porting a fix back is not always a simple task. We'll update this thread when that fix is made. You may want to upgrade to a more recent release to get the quickest fixes.

          Comment


            #6
            The nightlies dated 2017-12-07 should contain the fix for SGWT 5.1p/SC 10.1p.

            Comment


              #7
              Note that this only affected TreeGrids with initialData provided.

              Comment

              Working...
              X