How to create space between to TextField in SAP UI5 - sapui5

I have created three text boxes in sapui5. i want to separate those text boxes with spaces. I have tried with &nbsp spacing but that hasn't work. Please help me to solve this.

When I have to use a space I use "\u00a0".
So e.g.
createContent : function(oController) {
var content = [];
content.push(new sap.ui.commons.TextField({
value : "Field1"
}));
content.push(new sap.ui.commons.TextView({
text : "\u00a0"
}));
content.push(new sap.ui.commons.TextField({
value : "Field2"
}));
content.push(new sap.ui.commons.TextField({
value : "Field3"
}));
return content;
}
will create three TextFields, where the first and second are seperated by one space

Related

Adding new object to grid

I am trying to add a new record to existing grid in extjs 6 classic toolkit.
I will paste my code bellow, but first to explain what the problem is.
I use getCmp and getStore to fetch grid and store which will be used.
With Ext.ComponentQuery.query I get values from each field in the form to be added to the grid.
console.log(values) shows the values
Here is what I have so far:
getValuesForSave : function() {
var grid = Ext.getCmp('cataloguegrid');
var store = Ext.getStore('cataloguegridstore');
var model = store.model.create({});
var form = Ext.ComponentQuery.query("#basicDataPanel")[1];
var values = form.getValues();
console.log(values);
grid.getStore(model).insert(0, values);
Ext.MessageBox.show({
title : 'Saving data!',
msg : 'Data successfully saved!',
buttons : Ext.MessageBox.OK,
icon : Ext.Msg.INFO
});
},
I get no errors and a new row gets added to the grid, but the row is empty, it contains no data.
What changes do I need to make to be able to add an object to a grid?
Got it working. My problem was I did not set the "name" in form view to be the same as the "name" of items in form model. Changed that to match and it worked.
getValuesForSave : function() {
var grid = Ext.getCmp('cataloguegrid');
var form = Ext.ComponentQuery.query("#basicDataPanel")[1];
var values = form.getValues();
console.log(values);
grid.getStore().insert(0, values);
Ext.MessageBox.show({
title : 'Saving data!',
msg : 'Data successfully saved!',
buttons : Ext.MessageBox.OK,
icon : Ext.Msg.INFO
});
},

Smartface Repeatbox selectedItem is hiding

I added Repeatbox in the page. I getting json data. I set the useActiveItem as true. When I clicked the data, selectedItem is hiding. So, label is hiding. I want just give selected effect to row. How can I do this. My codes as follows.
//Data Source
var myDataSource = [{
row : "First Row"
}, {
row : "Second Row"
}, {
row : "Third Row"
}
];
//label element to be included
var lbl = new SMF.UI.Label({
top : "0%",
left : "0%",
width : "100%",
height : "100%",
fillColor : "#FFFFFF",
textAlignment : SMF.UI.TextAlignment.center,
touchEnabled:false
});
//repeatbox list
var repeatBox1 = new SMF.UI.RepeatBox({
width : "100%",
height : "80%",
left : "0%",
top : "0%",
showScrollbar : true
});
repeatBox1.dataSource = myDataSource;
repeatBox1.onRowRender = function (e) {
this.controls[0].text = myDataSource[e.rowIndex].row;
};
repeatBox1.onSelectedItem = function (e) {
alert("Selected " + (e.rowIndex + 1) + ". row");
};
repeatBox1.onLongTouch = function (e) {
alert("first row is deleted...");
};
repeatBox1.itemTemplate.height = Device.screenHeight / 7;
repeatBox1.itemTemplate.imageFillType = SMF.UI.ImageFillType.stretch;
repeatBox1.itemTemplate.add(lbl);
repeatBox1.useActiveItem=true;
Pages.Page4.add(repeatBox1);
Pages.Page4.add(repeatBox1);
You have to style each type of element in the Repeatbox (inactive, active, header, etc). To do that, go to design view and select the repeatbox, then you'll see a drop down menu that you can choose the different types of elements. Click "Active Item" and you'll notice that the row style is default again. Now style the row how you want the active style to be. And that's it. :)

Bind values dynamically to TextView properties in SAPUI5

I am designing a table with different columns filled with data, from an SAP OData backend, into textviews.
The design and semanticColor properties of the TextView are values received as a string. However loading fails with an error message: "String XY cannot be interpreted as design" // "..as semantic color" after binding in the following way..
oTable.addColumn(new sap.ui.table.Column({
template : new sap.ui.commons.TextView({
text : "{MyBackendElement}",
textAlign : sap.ui.core.TextAlign.Center,
design : "{Class}",
semanticColor : "{FontClass},
}),
visible : true,
}));
If I put in the design and semantic color directly, everything works fine, but how can I make this from my service? which data type does it need? Is it possible to transform the string defined in brackets {} for design and semantic color??
oTable.addColumn(new sap.ui.table.Column({
template : new sap.ui.commons.TextView({
text : "{MyBackendElement}",
textAlign : sap.ui.core.TextAlign.Center,
design : sap.ui.commons.TextViewDesign.Bold,
semanticColor : sap.ui.commons.TextViewColor.Critical,
}),
visible : true,
}));
The answer is partly in your question itself, the properties design and semanticColor only accept values of type sap.ui.commons.TextViewDesign and sap.ui.commons.TextViewColor.
However, as in your case you would be binding "strings" to these properties, you would need to ensure that the string is same as the last word of the possible list of values for the accepted types.
For example,
sap.ui.commons.TextViewDesign accepts
sap.ui.commons.TextViewDesign.Bold
sap.ui.commons.TextViewDesign.Italic
and so on. Therefore, you need to bring in "Bold" or "Italic" from your OData and bind it to the properties. Same goes for sap.ui.commons.TextViewColor
In your code snippet,
oTable.addColumn(new sap.ui.table.Column({
template : new sap.ui.commons.TextView({
text : "{MyBackendElement}",
textAlign : sap.ui.core.TextAlign.Center,
design : "{Class}",
semanticColor : "{FontClass},
}),
visible : true,
}));
'Class' would have values "Bold", "Italic"... and 'FontClass' would have "Critical", "Default"...
The list of allowed values for
sap.ui.commons.TextViewDesign is here
sap.ui.commons.TextViewColor is here

The control manages the rows aggregation. The method "addRow" cannot be used programmatically

I have a table that I want to distinguish between the items in the table by checking some condition and if the condition holds, i want to add row. but when I try to do that I get the error that:
The control manages the rows aggregation. The method "addRow" cannot be used programmatically!
var oTable = new sap.ui.table.Table({
width : "900px",
visibleRowCount : 10,
navigationMode : sap.ui.table.NavigationMode.Paginator
});
oTable.addColumn(new sap.ui.table.Column({
label : new sap.ui.commons.Label({
text : "Names"
})
}));
$.each(data, function(index,
nodes) {
if (nodes == something) {
oRow = new sap.ui.table.Row();
oRow.addCell(new sap.ui.commons.Link({
text : "something"
}));
oTable.addRow(oRow);
};
});
};
You cannot add data manually to the sap.ui.table.Table. This has to be done using databinding. Please check the examples in the documentation:
https://openui5.hana.ondemand.com/#test-resources/sap/ui/table/demokit/Table.html
you can find more information on data binding here:
https://openui5.hana.ondemand.com/#docs/guide/91f0ca956f4d1014b6dd926db0e91070.html

how to place textbox in dojo grid?

I have a requirement where i need place textbox in the cell and enter the value and have to read the value on submitaction. I have tried writing the code like below...
field : 'costCenter',
name : "Cost Center",
width : '180px',
height : '20px',
styles : "text-align: center;",
cellStyles : "text-align: left;font-weight: normal;",
classes : 'grid_header_title',
editable : true,
type : dojox.grid.cells.DateTextBox,
formatter: function(item){
var txt= new dijit.form.TextBox();
return txt;
this doesn't work for me. Can any one help me?
This will palce a textbox in your datagrid
var _count = 0;
{
field : 'costCenter',
name : "Cost Center",
style : "width: 180px; height: 20px; text-align: center;",
editable : true,
type : dojox.grid.cells._Widget,
formatter : function(){
return new dijit.form.TextBox({
id: "id_"+_count++
});
}
}