{
"content": [{
"type": "Panel",
"headerText": "Panel100",
"content": [{
"type": "Table",
"headerText": "Table100",
"columns": [{
"type": "Column",
"column": "A",
"cellType": ""
}, {
"type": "Column",
"column": "B",
"cellType": ""
}],
"rows": [{
"type": "ColumnListItem",
"A": 1000,
"B": 2000
}, {
"type": "ColumnListItem",
"A": 1000,
"B": 2000
}],
"layoutData": {
"indent": "L0 M0 S0",
"linebreak": false,
"span": "L2 M4 S6"
}
}],
"layoutData": {
"indent": "L0 M0 S0",
"linebreak": false,
"span": "L12 M12 S12"
}
}, {
"type": "TextArea",
"cols": 20,
"maxLength": 250,
"rows": 3,
"value": "abcd",
"width": "100%",
"layoutData": {
"indent": "L0 M0 S0",
"linebreak": false,
"span": "L6 M6 S6"
}
}, {
"type": "TextArea",
"cols": 20,
"maxLength": 250,
"rows": 3,
"value": "abcd",
"width": "100%",
"layoutData": {
"indent": "L0 M0 S0",
"linebreak": false,
"span": "L6 M6 S6"
}
}]
}
<App>
<pages>
<Page id="page">
<content>
<layout:Grid id="grid1" defaultSpan="XL12 L12 M12 S12" defaultIndent="XL0 L0 M0 S0" content="path:'viewContent>/content',templateShareable:'false', factory: '.createDynamicContent'}" class="sapUiNoContentPadding">
<layout:content></layout:content>
</layout:Grid>
</content>
</Page>
</pages>
</App>
onInit: function () {
oController = this;
oController.getView().setModel(new JSONModel("./model/Contents.json"), "viewContent"); // this is the same json object defined above
},
createDynamicContent: function (sId, oContext) {
var contextObject = oContext.getObject();
var type = contextObject.type
var gridData = contextObject.layoutData;
switch (type) {
case "Panel":
return new Panel({
expandable: true,
expanded: false,
width: "auto",
headerText: {
path: 'viewContent>headerText'
},
content: {
path: 'viewContent>content',
templateShareable: false,
factory: oController.createDynamicContent
},
layoutData: new GridData(gridData)
});
break;
case "TextArea":
return new TextArea({
cols: {
path: 'viewContent>Cols'
},
maxLength: {
path: 'viewContent>maxLength'
},
rows: {
path: 'viewContent>rows'
},
value: {
path: 'viewContent>value'
},
width: {
path: 'viewContent>width'
},
layoutData: new GridData(gridData)
});
break;
case "Table":
return new Table({
headerText: {
path: 'viewContent>headerText'
},
columns: {
path: 'viewContent>columns',
templateShareable: false,
factory: oController.createDynamicContent
},
items: {
path: 'viewContent>rows',
factory: oController.createDynamicContent,
templateShareable: false
},
layoutData: new GridData(gridData)
});
break;
case "Column":
return new Column({
header: new Label({
text: {
path: 'viewContent>column'
}
})
})
break;
case "ColumnListItem":
{
var cells = [];
contextObject['columns'].forEach(function (oCell) {
if (oCell["column"]) {
cells.push(oContext.getObject().ctrlKey_inedit ?
new Input({
value: {
path: 'viewContent>' + oCell["column"]
}
}) : new Text({
text: {
path: 'viewContent>' + oCell["column"]
},
}));
} else {
cells.push(new sap.ui.core.InvisibleText({}));
}
});
return new ColumnListItem({
cells: cells
});
break;
}
default:
return new Text({
text: "no contoll defined in factory for this type"+type
});
}
}
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
5 | |
5 | |
5 | |
4 | |
4 | |
4 | |
4 | |
3 | |
3 | |
3 |