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. :)
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);
}
The following code was working with Smartface 4.2.4 but the same code crashes for Smartface 4.3. Did something change in the new version?
function Page1_ImageButton3_OnTouch(e){
showDate();
}
function showDate(){ SMF.UI.showDatePicker({
CurrentDate : new Date(), // date is given with JS date object
mask : "YYYY-MM-DD",
minDate:new Date("2000-01-01"),
maxDate:new Date("2030-12-01"),
showWorkingDate : true,
onSelect : function(e) {
alert("Working!")
}
});
}
Why did you set 2030 on maxDate?
Anyway, you have missed and write wrong some properties of datepicker object. You can try this it will work iOS and Android:
SMF.UI.showDatePicker({
mask : "yyyy-MM-dd",
currentDate : new Date(),
minDate : new Date("2000-01-01"),
maxDate : new Date("2030-12-01"),
showWorkingDate : true,
displayMode : 2,
onSelect : function (e) {},
onCancel : function (e) {}
});
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();