Quantcast
Channel: SCN: Message List
Viewing all articles
Browse latest Browse all 9269

XML View & Model, Tree & binding

$
0
0

Hi there,

 

i'm trying to do some stuff with XML models, XML Views and Trees.

 

Here is my xml model file :

<objectSet version="1.2.3.4">    <aRoot code="testCode" reference="0123456789" description="TestDescription" owner="Tester">            <component name="MyCompo1" type="MyCompo1Type">              <component name="MyCompo2" type="MyCompo2Type">               <property name="myProperty2-1" type="string" value="null"/>              </component>              <component name="MyCompo3" type="MyCompo3Type">               <property name="myProperty3-1" type="string" value="null"/>              </component>            </component>    </aRoot></objectSet>

 

My XML View file :

<core:View xmlns:core="sap.ui.core" xmlns:mvc="sap.ui.core.mvc" xmlns="sap.m" xmlns:cmn="sap.ui.commons"        controllerName="cleanproject.TreeTest" xmlns:html="http://www.w3.org/1999/xhtml">                <cmn:Tree nodes="{/aRoot}">                <cmn:TreeNode text="{@name} TagNameHere?"></cmn:TreeNode>                </cmn:Tree></core:View>

 

My Js Controller file :

sap.ui.controller("cleanproject.TreeTest", {
onInit: function() {
var xmlModel =  new sap.ui.model.xml.XMLModel("cleanproject/"+xmlPath3);
xmlModel.setXML("the full xml document here"); // bad trick
this.getView'().setModel(xmlModel);
},
}

 

I have multiples questions :

  1. What is the way to wait the xml file to be loaded, because when i'm not using setXML function in my controller, the view is instantiated too fast  and an error is raised as the model is not accessible ( Error message : "N is null" )
  2. Is it possible to display in a TreeNode the tagName of an element? ( e.g : "component", "property" )
  3. Is it possible to build the tree only with "component" TreeNodes ?

 

Thanks for helping,

Regards,

Marc

 

Edit : 4. Is it possible to bind a part of the datas , eg : bind with a deepth of 1,2,...n ?

 

Edit2: Some answers found

 

1. In the onInit function, use attachRequestCompleted method. In my case :

var thus= this;        xmlModel.attachRequestCompleted(function(event){            thus.getView().setModel(xmlModel);        });

 

2. ?

 

3. It does not seem possible even with filters

 

4. Can be done using javascript and a custom method


Viewing all articles
Browse latest Browse all 9269

Trending Articles