Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

sap.m.Tree ChildNodes Failure in Mockserver with MockData #1220

Closed
HaShLo opened this issue Nov 8, 2016 · 3 comments
Closed

sap.m.Tree ChildNodes Failure in Mockserver with MockData #1220

HaShLo opened this issue Nov 8, 2016 · 3 comments
Labels

Comments

@HaShLo
Copy link

HaShLo commented Nov 8, 2016

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

@DMihaylova
Copy link
Contributor

Hi @HaShLo ,

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

Kind Regards,
Diana, SAPUI5 Dispatcher

@DMihaylova DMihaylova added the bug label Nov 30, 2016
@awui
Copy link
Contributor

awui commented Nov 30, 2016

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)

@HaShLo
Copy link
Author

HaShLo commented Dec 1, 2016

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants