openui5 icon indicating copy to clipboard operation
openui5 copied to clipboard

sap.m.Tree ChildNodes Failure in Mockserver with MockData

Open HaShLo opened this issue 10 years ago • 3 comments

Hi everyone,

sap.m.Tree dont show the childnodes of the parentnodes with a mockserver + mockdata, instead it says technical error with log: { "message": "HTTP request failed", "headers": { "Content-Type": "application/json;charset=utf-8", "DataServiceVersion": "2.0" }, "statusCode": "400", "statusText": "Bad Request", "responseText": "{\"error\":{\"code\":400,\"message\":{\"lang\":\"en\",\"value\":\"Invalid system query options value\"}}}" }

Debugging result was, that it request this path at expand the parentnode: 'Modules?$filter=parentId%20eq%2013&$skip=0&$top=1.7976931348623157e+308'

1.7976931348623157e+308????? -> it is this line in Tree.js: aContexts = oBinding.getContexts(0, Number.MAX_VALUE);

Dirty Solution was to implement this line from Tree.js in own Controller: // Get all nodes. aContexts = oBinding.getContexts(0, Number.MAX_VALUE); to aContexts = oBinding.getContexts(0, 10000);

Changed Code in my own Controller: ` Tree.prototype.updateItems = function(sReason) { // Reuse the ListBinding from ManagedObject.updataAggregation var oBindingInfo = this.getBindingInfo("items"), oBinding = this.getBinding("items"), fnFactory = oBindingInfo.factory, aContexts;

	// Update a single aggregation with the array of contexts. Reuse existing children
	// and just append or remove at the end, if some are missing or too many.
	function update(oControl, aContexts) {
		var aChildren = oControl.getItems() || [],
			oContext,
			oClone;
		if (aChildren.length > aContexts.length) {
			for (var i = aContexts.length; i < aChildren.length; i++) {
				oControl.removeItem(aChildren[i]);
				aChildren[i].destroy("KeepDom");
			}
		}
		for (var i = 0; i < aContexts.length; i++) {
			oContext = aContexts[i];
			oClone = aChildren[i];
			if (oClone) {
				oClone.setBindingContext(oContext, oBindingInfo.model);
			} else {
				oClone = fnFactory(oControl.getId() + "-" + i, oContext);
				oClone.setBindingContext(oContext, oBindingInfo.model);
				oControl.addItem(oClone);
			}
		}
	}

	// Get all nodes.
	aContexts = oBinding.getContexts(0, 10000);

	// If factory function is used without extended change detection, destroy aggregation
	if (!oBindingInfo.template) {
		this.destroyItems();
	}
	update(this, aContexts);

};`

OpenUI5 version: 1.45.0-SNAPSHOT

Browser/version (+device/version): Google Chrome Version 54.0.2840.71 m (64-bit)

Steps to reproduce the problem:

  1. Create a new Project with mockserver and mockdata
  2. One Entity in metadata.xml with Properties: drillstate, parentid, hierarchyLevel, id
  3. Create a sap.m.Tree in View with Parameters: items="{ path : '/Entities', parameters : { treeAnnotationProperties : { hierarchyLevelFor : 'hierarchyLevel', hierarchyNodeFor : 'id', hierarchyParentNodeFor : 'parentId', hierarchyDrillStateFor : 'drillState' } } }"

What is the expected result? Show the ChildNodes without a failure

What happens instead? Technical Error (Log Message see above)

Any other information? (attach screenshot if possible)

bild1 bild2

MockServer-dbg.js: bild4

Tree.js: bild5

MockData JSON File: json

DIRTY SOLUTION

OwnController.js: bild6

Result: bild7

Please fix it, thanks...

Best regards

HaShLo

HaShLo avatar Nov 08 '16 15:11 HaShLo

Hi @HaShLo ,

Thank you for reporting the ticket. Internal reference: #1680294243.

Kind Regards, Diana, SAPUI5 Dispatcher

DMihaylova avatar Nov 30 '16 10:11 DMihaylova

Hi @HaShLo, could you please provide the link to your system or snippix so that we can debug and fix the issue?

Thanks and regards, Wenqian (SAP UI5 Dev)

awui avatar Nov 30 '16 12:11 awui

Hi @HaShLo, could you please provide the link to your system or snippix so that we can debug and fix the issue? Thanks and regards, Wenqian (SAP UI5 Dev)

Hi awui,

i dont know what you mean.

If you want the code , i can paste it here:

a view.xml:

<Tree id="Tree" enableBusyIndicator="false" mode="MultiSelect" items="{ path : '/Modules', parameters : { treeAnnotationProperties : { hierarchyLevelFor : 'hierarchyLevel', hierarchyNodeFor : 'id', hierarchyParentNodeFor : 'parentId', hierarchyDrillStateFor : 'drillState' } } }" > <StandardTreeItem title="{text}"/> </Tree>

make a odata model then one entity with properties above at treeAnotationProperties. All this things do it on mockserver and mockdata( i dont know if you have it to on a real server you must look). Thats it to reproduce.

You must only change:

// Get all nodes. aContexts = oBinding.getContexts(0, Number.MAX_VALUE);

to

// Get all nodes. aContexts = oBinding.getContexts(0, 10000);

in Tree.js...

Thats the Fix i think !

Thx

HaShLo avatar Dec 01 '16 11:12 HaShLo