I want to disable touchEnabled property of SliderDrawer1. But this is not working when I write this code. How can I do this? My codes as follows.
function Page1_Self_OnShow() {
var timeoutID = setTimeout(function () {
setHello();
}, 200);
function setHello() {
Pages.Page1.SliderDrawer1.touchEnabled=false;
Pages.Page1.SliderDrawer1.show();
cancelHello();
}
function cancelHello() {
clearTimeout(timeoutID);
}
}
It is native behaviour for SliderDrawer.So, yo can use Container or Rectangle, place it like sliderdrawer and add objects in Container as below:
var myContainerLayout = new SMF.UI.Container({
top : "0%",
left : "0%",
width : "40%",
height : "100%",
backgroundTransparent : false,
fillColor : SMF.UI.Color.black,
});
var myButton = new SMF.UI.TextButton({
top : "10%",
left : "5%",
height : "15%",
text : "button"
});
Pages.Page1.add(myContainerLayout);
myContainerLayout.add(myButton);
}
I am working with sap.m.table. I have requirement to apply or change the background color for some of the rows based on the data in one of the column in those rows in table.
I am using the following code but it is not working
created the CSSfile: test.css
<style type="text/css">
.Total {
background-color: LightSteelBlue !important;
}
</style>
The above CSS file declare in Component.js like the following way ( correct me if this not right way to make the css file available to access in whole ui5 project.
"resources": {
"css": [
{
"uri": "css/test.css"
}
]
}
In Controller.i have defined the following method to apply the style sheet for the particular rows alone in table.
rowColours: function() {
var oController = this;
console.log("rowColours() --> Start ");
var oTable = this.oView.byId("tblAllocation");
var rows = oTable.getItems().length; //number of rows on tab
//start index
var row;
var cells = [];
var oCell = null;
for (i = 0; i < oTable.getItems().length; i++) {
//console.log("rowColours() :: row--> "+row);
//actualRow = oTable.getItems(); //content
if (i == 0) {
row = oTable.getItems()[i];
cells = cells.concat(oTable.getItems()[i].getCells());
//getting the cell id
oCell = cells[2];
oCell = oCell.toString().substring(29, oCell.length);
otemp = this.getView().byId(oCell).getText();
if (otemp.toString() == "TotalAllocation") {
oTable.getItems()[i].$().taggleClass("grandTotal");
}
}
}
console.log("rowColours() --> end ");
}
In the above method. I am checking the cell2 data ( in table cell 2 i was using the Textview control to display the data. when call this method to get the data in that cell. I am getting the following error.
otemp = this.getView().byId(oCell).getText());
error:
Uncaught TypeError: Cannot read property 'getText' of undefined
is the following code is possible to change the row bg color.
if (otemp.toString() == "TotalAllocation") {
oTable.getItems()[i].$().taggleClass("Total");
}
Please let me know how to change the bg color or applying the style for the perticular row in sap.m.table
Thanks
The approach your following is not right. Better you can use a formatter.
Example:
var oTable = new sap.m.Table({
columns: [
new sap.m.Column({
header: new sap.m.Label({
text: "Name"
}),
}),
],
items: {
path: 'modelList>/',
template: new sap.m.ColumnListItem({
cells: [
new sap.m.Text({
//formatter to the text property on sap.m.Text control.
text: {
parts: [{
"path": "modelList>Name"
}],
formatter: function(name) {
if (name == "TotalAllocation") {
// use this.getParent().. until u get the row. like this below and add class.
this.getParent().getParent().addStyleClass("Total");
}
}
}
})
]
})
}
});
I have a simple question. I'm trying to use animation on a single page such as Page1. For example if I change the Label text and press a TextButton, I would like it to transition leftToRight. When I try to use the Pages.Page1.show(3,4,0,false,false), the updated label is shown with no transition effect. I've tried to go between 2 different pages and it does transition properly. Is there a way to do this with 1 page since I want to keep the same page elements but just update the text content and display the updated page with a transition effect.
You can not run page animation for the same page. But you can try something like that.
Just run animate method only for the updated object. For example;
var myLabel = new SMF.UI.Label({
top : "25%",
left : "15%",
height : "10%",
width : "70%",
text : "hello"
});
var myButton = new SMF.UI.TextButton({
top : "50%",
left : "15%",
height : "10%",
width : "70%",
text : "myButton",
onPressed : function () {
myLabel.alpha = 0;
myLabel.text = "world";
myLabel.animate({
property : "alpha",
endValue : 100,
motionEase : SMF.UI.MotionEase.plain,
duration : 3000,
onFinish : function () {
//do your action after finishing the animation
}
});
}
});
Add these two objects(myLabel, myButton) to your page.
When pressed to button, label's text changes, it becomes invisible with alpha = 0, and then it becomes visible again with animate method.
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++
});
}
}
I am getting the following message in the logs and a buggy navigation group
2011-10-27 21:41:21.575 bugtitanium[15903:207] nested push animation can result in corrupted navigation bar
2011-10-27 21:41:21.945 bugtitanium[15903:207] Finishing up a navigation transition in an unexpected state. Navigation Bar subview tree might get corrupted.
2011-10-27 21:41:21.946 bugtitanium[15903:207] Finishing up a navigation transition in an unexpected state. Navigation Bar subview tree might get corrupted.
Attaching the code to reproduce ; on the first load, everything is ok, hit 1 time reload , click on one row and click the back button
Do the same and reload 2 times, you will have to hit the back button 2 times, and so on ....
Can someone provide me with a workaround or a fix please ?
I need to load and populate the table as async processes
the code is
Titanium.UI.setBackgroundColor('#000');
var tabGroup = Titanium.UI.createTabGroup();
var win1 = Titanium.UI.createWindow({
title:'Tab 1',
backgroundColor:'#fff'
});
var mytasks_helping_button = Ti.UI.createButton({
title : 'Reload',
top:0,
color:'black',
width:200,
height:30,
style:Ti.UI.iPhone.SystemButtonStyle.BORDERED
});
win1.add(mytasks_helping_button);
var mytasks_helping_tableview = Titanium.UI.createTableView({
top:100
});
win1.add(mytasks_helping_tableview);
var tab1 = Titanium.UI.createTab({
icon:'KS_nav_views.png',
title:'Tab 1',
window:win1
});
function populateData(datasourcetmp,tabletmp){
var data = [];
for( i = 0; i < datasourcetmp.length; i++) {
var row = Titanium.UI.createTableViewRow({
height : 120,
backgroundColor:'#fff',
borderWidth : 0,
borderColor : 'transparent'
});
var my_tasks_table_top_label = Titanium.UI.createLabel({
text : 'test row:'+i+' date:'+new Date(),
width : "100%",
font : {
fontSize : 12,
fontFamily : 'Helvetica'
},
color : "black",
top : 30,
height : 20,
left : 5
});
row.add(my_tasks_table_top_label);
data.push(row);
};
mytasks_helping_tableview.addEventListener('click', function(e) {
//view a task screen
var viewTask = Titanium.UI.createWindow({
height : "100%",
width : "100%",
title : "Helping with",
barColor : 'lightGray'
});
var viewTask_top_label = Titanium.UI.createLabel({
text : 'nested view '+ e.index,
width : "80%",
font : {
fontSize : 15,
fontFamily : 'Helvetica'
},
color : "gray",
top : 10,
height : 20,
left : 60
});
viewTask.add(viewTask_top_label);
tab1.open(viewTask);
});
tabletmp.setData(data);
}
var datasource = ['1','2','3','4','5','6','7'];
populateData(datasource,mytasks_helping_tableview);
mytasks_helping_button.addEventListener('click', function(e) {
populateData(datasource,mytasks_helping_tableview);
});
tabGroup.addTab(tab1);
tabGroup.open();
In the code above, you are adding an event listener every time you call populateData.
mytasks_helping_tableview.addEventListener('click', function....
Adding a event listener does NOT 'replace' the existing event listener so it is firing multiple time after the first 'load' and opening multiple windows.
Just move the mytasks_helping_tableview.addEventListener call to outside the populateData function.
Actually a more flexible way to fix that enable the code to by used by different table comp is to create a map of table instances and every time delete the previous instance and rebuild
Titanium.UI.setBackgroundColor('#000');
var tabGroup = Titanium.UI.createTabGroup();
var win1 = Titanium.UI.createWindow({
title:'Tab 1',
backgroundColor:'#fff'
});
var mytasks_helping_button = Ti.UI.createButton({
title : 'Reload',
top:0,
color:'black',
width:200,
height:30,
style:Ti.UI.iPhone.SystemButtonStyle.BORDERED
});
win1.add(mytasks_helping_button);
var tab1 = Titanium.UI.createTab({
icon:'KS_nav_views.png',
title:'Tab 1',
window:win1
});
var tableView={};
function populateData(datasourcetmp,tableName){
if(tableView[tableName]){
win1.remove(tableView[tableName]);
delete tableView[tableName];
}
var tabletmp = Titanium.UI.createTableView({
top:100
});
win1.add(tabletmp);
tableView[tableName] = tabletmp;
var data = [];
for( i = 0; i < datasourcetmp.length; i++) {
var row = Titanium.UI.createTableViewRow({
height : 120,
backgroundColor:'#fff',
borderWidth : 0,
borderColor : 'transparent'
});
var my_tasks_table_top_label = Titanium.UI.createLabel({
text : 'test row:'+datasourcetmp[i]+' date:'+new Date(),
width : "100%",
font : {
fontSize : 12,
fontFamily : 'Helvetica'
},
color : "black",
top : 30,
height : 20,
left : 5
});
row.add(my_tasks_table_top_label);
data.push(row);
};
tabletmp.addEventListener('click', function(e) {
//view a task screen
var viewTask = Titanium.UI.createWindow({
height : "100%",
width : "100%",
title : "Helping with",
barColor : 'lightGray'
});
var viewTask_top_label = Titanium.UI.createLabel({
text : 'nested view '+ e.index,
width : "80%",
font : {
fontSize : 15,
fontFamily : 'Helvetica'
},
color : "gray",
top : 10,
height : 20,
left : 60
});
viewTask.add(viewTask_top_label);
tab1.open(viewTask);
});
tabletmp.setData(data);
}
var datasource = ['1','2','3'];
populateData(datasource,'mytasks');
mytasks_helping_button.addEventListener('click', function(e) {
datasource = ['4','5','6','7'];
populateData(datasource,'mytasks');
});
tabGroup.addTab(tab1);
// open tab group
tabGroup.open();