Announcement

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

    Multiple requests with dataFetchModepaged in TreeGrid

    Trying to use "dataFetchMode: paged" in TreeGrid results in multiple calls for the data. With the example below you can reproduce this behaviour and check that there are 4 requests where it should only be one to get the first data. In the resuet to the datasource the parentId is not set either in our application nor in the example. Do we have to set the parentId by ourself in the initial request?

    We using the latest nightly SmartClient_v100p_2014-11-26_Pro and it happens with all browsers.

    Code:
    isc.VLayout.create(
     {
      "width":"100%",
      "height":"100%",
      "autoDraw":true,
      "members":
      [ isc.TreeGrid.create(
        {
         "width":"100%",
         "height":"100%",
         "hideUsingDisplayNone":false,
         "leaveScrollbarGap":true,
         "selectionType":"single",
         "canEdit":false,
         "timeFormatter":"toShortTime",
         "sortField":"nil",
         "sortDirection":"ascending",
         "clwGeneratedIndexName":"nameTreeGridGeneratedIndex",
         dataSource : isc.DataSource.create({
    		"fields" :
    		[{
    				"name" : "term",
    				"type" : "text"
    			}
    		],
    		"dataFormat" : "json",
    		"useHttpProxy" : false,
    		"dataURL" : "http://www.corsproxy.com/www.openthesaurus.de/synonyme/search?q=aber&format=application/json",
    		"recordXPath" : "/synsets[3]/terms"
          }),
         "autoFetchData":true,
         "dataPageSize":120,
         "dataFetchMode":"paged",
         "fields":
         [
          {
           "name":"term",
           "title":"Name",
           "type":"text",
          }      
         ]
        }
        )
      ]
     }
     )

    #2
    Your DataSource is not a valid tree DataSource - no settings for foreignKey, rootValue, etc. See the Tree DataBinding overview.

    Comment


      #3
      ok, we have tried to reproduce this with a small example. But it seems that this results in a defect-databinding. Sorry.

      What makes us wonder is the example in
      http://www.smartclient.com/docs/release/a/system/reference/SmartClient_Explorer.html#pagingForChildren

      Analyzing the request made there we have discovered a strange request. There is only made one request, but it seems that the request-data repeats 3 times.
      The first xml "<elem xsi:type="xsd:Object">" node has the property of startRow and endRow. The second and third haven't got this attributes.
      This is also the case with our problem we have. The first request has set startRow and endRow correctly, but the second and third request has there a null value.
      Shouldn't be there only one elem-node? If not, why are there multiple elem-nodes?

      Maybe this results into 3 seperate requests if you don't handle it via xml datasource-requests? That would be some kind of comparable to our problem.
      Code:
      <transaction xmlns:xsi="http://www.w3.org/2000/10/XMLSchema-instance" xsi:type="xsd:Object">
      	<transactionNum xsi:type="xsd:long">8</transactionNum>
      	<operations xsi:type="xsd:List">
      		<elem xsi:type="xsd:Object">
      			<criteria xsi:type="xsd:Object">
      				<parent xsi:nil="true"/>
      			</criteria>
      			<operationConfig xsi:type="xsd:Object">
      				<dataSource>hugeTree</dataSource>
      				<operationType>fetch</operationType>
      				<textMatchStyle>exact</textMatchStyle>
      			</operationConfig>
      			<startRow xsi:type="xsd:long">0</startRow>
      			<endRow xsi:type="xsd:long">75</endRow>
      			<componentId>isc_TreeGrid_0</componentId>
      			<appID>builtinApplication</appID>
      			<operation>hugeTree_fetch</operation>
      			<oldValues xsi:type="xsd:Object">
      				<parent xsi:nil="true"/>
      			</oldValues>
      			<resultTreeIdField>id</resultTreeIdField>
      			<resultTreeParentIdField>parent</resultTreeParentIdField>
      		</elem>
      		<elem xsi:type="xsd:Object">
      			<criteria xsi:type="xsd:Object">
      				<parent xsi:nil="true"/>
      			</criteria>
      			<operationConfig xsi:type="xsd:Object">
      				<dataSource>hugeTree</dataSource>
      				<operationType>fetch</operationType>
      				<textMatchStyle>exact</textMatchStyle>
      			</operationConfig>
      			<componentId>isc_TreeGrid_0</componentId>
      			<appID>builtinApplication</appID>
      			<operation>hugeTree_fetch</operation>
      			<oldValues xsi:type="xsd:Object">
      				<parent xsi:nil="true"/>
      			</oldValues>
      			<resultTreeIdField>id</resultTreeIdField>
      			<resultTreeParentIdField>parent</resultTreeParentIdField>
      		</elem>
      		<elem xsi:type="xsd:Object">
      			<criteria xsi:type="xsd:Object">
      				<parent xsi:nil="true"/>
      			</criteria>
      			<operationConfig xsi:type="xsd:Object">
      				<dataSource>hugeTree</dataSource>
      				<operationType>fetch</operationType>
      				<textMatchStyle>exact</textMatchStyle>
      			</operationConfig>
      			<componentId>isc_TreeGrid_0</componentId>
      			<appID>builtinApplication</appID>
      			<operation>hugeTree_fetch</operation>
      			<oldValues xsi:type="xsd:Object">
      				<parent xsi:nil="true"/>
      			</oldValues>
      			<resultTreeIdField>id</resultTreeIdField>
      			<resultTreeParentIdField>parent</resultTreeParentIdField>
      		</elem>
      	</operations>
      </transaction>

      Comment


        #4
        We can't see anything wrong with this request.

        Also, don't try to read the raw XML of the request, you'll just confuse yourself as this is not a documented format. You can see the request displayed in more readable form in either the RPC tab of the Developer Console, or in the server side logs.

        Comment


          #5
          ok, i won't try to tried the raw xml any more. For me that doesn't look like an coincidence, but here i can be false.

          Despite the fact that in the first example we have posted not a valid tree-DataSource there are also three requests in the example, which we also have in our test integration in our product. The tree works like desired, but initially there are three requests , but there should be only one.

          In our integration to our production code the first request has these values:
          Code:
          {
          	end : 60,
          	id : nameTreeGrid,
          	operationType : fetch,
          	parentId : null,
          	sessionId : E2C65AC8AFBC75411180D0C32585C577A4687CA9,
          	sortBy : null,
          	start : 0,
          	viewNumber : 2
          }
          The second and third requests looks the same like
          Code:
          {
          	end : null
          	id : nameTreeGrid
          	operationType : fetch
          	parentId : null
          	sessionId : E2C65AC8AFBC75411180D0C32585C577A4687CA9
          	sortBy : null
          	start : null
          	viewNumber : 2
          }
          Because the initial root is not set the parentId is corrrectly referenced with a "null"-value. Therefore we can identify that the request is requesting the root-node.

          The "magic" happens with the second and third request. I think this requests should not be trigered in any way. It's kind of strange that in the second and third request the start: and end: are empty, we are getting these parameters directly from the datasourceRequest
          Code:
          var params = {
          	sortBy: dataSourceRequest.sortBy,
          	start : dataSourceRequest.startRow,
          	end : dataSourceRequest.endRow
          };
          In the RPC tab like you suggeseted the requests are not displayed. The Treegrid is working with transformRequest and transformResponse. It uses json as dataFormat and it's a GET-request.

          So do you have any suggestion which could lead us to a solution to reduce the inital three datasource-requests to the only needed one request?

          Comment


            #6
            Yes, we have a suggestion: provide a valid Tree DataSource. See the Tree DataBinding topic in the SmartClient Reference.

            You're seeing 3 requests occur in a situation where you've provided invalid settings. Behavior of the framework in this case is totally undefined, so we're not sure why you're still trying to investigate this situation - it can't possibly lead to a valid bug report.

            Comment


              #7
              Ok, we have tried to follow your suggestion. We have set foreignKey and rootValue. Because of this the parentId is now correctly set in the initial request.

              This is surely better than before, because we get the right parentId. Sorry for not geting this at the firt time. Sadly we are still getting 3 initial requests. We have read the documentation and we think we have defined all attributes needed for the first prototype. But maybe there are some attributes we have to also set to get this done with only one needed request.

              Could you give us another suggestion, what attributes are missing in our definition that might lead to the three requests? We also have attached the debug-log(at the bottom of this post) that is printed in the showLog()-console. Maybe there are some mor informations about missing attributes in our definition?

              The definition of the treegrid is currently this:
              Code:
              isc.TreeGrid.create({
              	"ID" : "nameTreeGrid_2",
              	"width" : "100%",
              	"height" : "100%",
              	"selectionType" : "single",
              	"autoFetchData" : true,
              	"dataPageSize" : 60,
              	"dataFetchMode" : "paged",
              	dataSource : isc.DataSource.create({
              		"parentIdField" : "parentId",
              		"fields" :
              		[{
              				"name" : "parentId",
              				"type" : "integer",
              				"foreignKey" : "id",
              				"rootValue" : "0"
              			}, {
              				"name" : "nameField",
              				"title" : "Name",
              				"type" : "text"
              			}, {
              				"name" : "lastNameField",
              				"title" : "lastName",
              				"type" : "text",
              			}
              		],
              		"dataFormat" : "json",
              		"dataURL" : "/cgi-bin/hrw.dll/ScTreeGridDataSource?viewNumber=2&id=nameTreeGrid",
              		"transformRequest" : clwTransformRequest,
              		"transformResponse" : clwTransformResponse,
              		"recordXPath" : "\/resultData"
              	}),
              	"fields" :
              	[{
              			"name" : "nameField",
              			"title" : "Name",
              			"type" : "text"
              		}, {
              			"name" : "lastNameField",
              			"title" : "lastName",
              			"type" : "text"
              		}
              	]
              })
              The first request looks like this:
              Code:
              end	60
              id	nameTreeGrid
              operationType	fetch
              parentId	0
              sessionId	FC9EEBE5F3FC3403DB52E5F88C9694D6D74ED271
              sortBy	null
              start	0
              The second and third like this:
              Code:
              end	null
              id	nameTreeGrid
              operationType	fetch
              parentId	0
              sessionId	FC9EEBE5F3FC3403DB52E5F88C9694D6D74ED271
              sortBy	null
              start	null
              The debug-log could be found in http://pastebin.com/MABcdMZW or http://pastebin.com/raw.php?i=MABcdMZW

              Best Regards

              Comment

              Working...
              X