How to move items in listbox to its original position - sapui5

I have a listbox with several listitems, I post one for example:
var listboxChooseColumns = new sap.ui.commons.ListBox("chooseColumns", {
allowMultiSelect: true,
items: [
nameItem,
new sap.ui.core.ListItem({
text: "Functional Location",
test: "lastName"
})
]
})
The listitems from one box can be moved to another one:
var moveAllToTableColumn = new sap.ui.commons.Button({
press: function() {
//var selectedItems = listboxChooseColumns.getSelectedItems();
var selectedItems = listboxChooseColumns.getItems();
for (var i=0; i<selectedItems.length;i++) {
var listItem = selectedItems[i];
listBoxChosenColumns.addItem(listItem);
}
}
});
If I want to bring the item back from the second list to the first one, the item goes to the end of the list, not in its initial position.
var moveFromTableColumn = new sap.ui.commons.Button({
press: function(){
var selectedItems = listBoxChosenColumns.getSelectedItems();
for (var i=0; i<selectedItems.length;i++) {
var listItem = selectedItems[i];
listBoxChosenColumns.removeItem(listItem);
listboxChooseColumns.addItem(listItem);
}
}
});
How can I return item from the second list to the first list into initial position?

Instead of addItem(), consider using insertItem(oItem, iIndex) which allows you to position the item being inserted (e.g. at the top, if you specify 0 for iIndex):
listboxChooseColumns.insertItem(listItem, 0);

Related

How to get all dropdown selected item value and push to another oData in SAPui5?

All dropdown selected item value getting from first oDATA and Second oDATA.
Once select or choose all dropdown
value item then
I want to push all
selected item value to third oDATA.(Eg: After click Append button)
Sample Screenshot Image Output Code below:
function() {
//get first dropdown box selected key from first odata
var plant = sap.ui.getCore().byId("plant").getSelectedKey();
if (plant != 0) {
var sServiceUrl = "/sap/opu/odata/SAP/Z_M_EPM_BOM_SRV/";
var oModel = new sap.ui.model.odata.ODataModel(sServiceUrl, true);
var filterList = [];
var i;
filterList.push(new sap.ui.model.Filter("Plant", sap.ui.model.FilterOperator.EQ, plant));
// first dropdown box selected value filter to second odata key
oModel.read("/MatCharFieldSet", {
context: null,
async: false,
filters: filterList,
urlParameters: {
"$expand": "MatCharValuesSet"
},
success: function(data) {
var res = data.results;
var content = [];
for (i = 0; i < res.length; i++) {
content.push(new sap.m.Label({
text: res[i].DescrChar,
name: res[i].FieldName
}));
var items = [];
for (var j = 0; j < res[i].MatCharValuesSet.results.length; j++) {
items.push(new sap.ui.core.Item({
text: res[i].MatCharValuesSet.results[j].FieldValue,
key: res[i].MatCharValuesSet.results[j].FieldValue
}));
}
content.push(new sap.m.Select({
items: items
}));
}
fields = new sap.ui.layout.form.SimpleForm({
editable: true,
layout: sap.ui.layout.form.SimpleFormLayout.ResponsiveGridLayout,
labelSpanL: 4,
labelSpanM: 4,
adjustLabelSpan: true,
emptySpanL: 0,
emptySpanM: 0,
columnsL: 4,
columnsM: 4,
content: content
});
fields.placeAt("fields", "only");
}
How to push all selected value item to another oDATA ?
SAMPLE SCREENSHOT
var getAllSelectInstances = $(".sapMSlt").control();
getAllSelectInstances.forEach(function(oSelect){
var getSelectedItem = oSelect.getSelectedItem();
var getSelectedText = getSelectedItem ? getSelectedItem.getText() : null;
Console.log("Selected Value : " + getSelectedText);
});

NativeScript - how can I filter an observable array with SearchBar?

Hi I'm trying to filter an observable array of data fetched via a HTTP request on keypress of the SearchBar.
I managed to get the SearchBar property change to work but I can't seem to figure out what I'm doing wrong in the filtering logic.
Ideally I want to update the list as I type in the search term in the SearchBar. I've searched the API on the Telerik site, there wasn't really any examples I could find.
XML
<Page loaded="pageLoaded">
<ActivityIndicator busy="{{ isLoading }}" />
<ActionBar title="People">
</ActionBar>
<GridLayout>
<StackLayout>
<SearchBar id="searchBar" hint="Search for someone"></SearchBar>
<ListView items="{{ peopleList }}" itemTap="showDetail">
<ListView.itemTemplate>
<StackLayout>
<Label text="{{ fullName }}" horiztonalAlignment="left" verticalAlignment="center"></Label>
<Label text="{{ company }}" class="info"></Label>
</StackLayout>
</ListView.itemTemplate>
</ListView>
</StackLayout>
</GridLayout>
</Page>
JS
var frames = require("ui/frame");
var Observable = require("data/observable").Observable;
var PeopleListViewModel = require("../../shared/people-viewModel");
var activityIndicatorModule = require("ui/activity-indicator");
var page;
var userkey;
var peopleList = new PeopleListViewModel([]);
var pageData = new Observable({ peopleList: peopleList });
exports.pageLoaded = function(args) {
page = args.object;
page.bindingContext = pageData;
userkey = userkey || page.navigationContext.userkey;
peopleList.load(userkey); // fetch data from the backend
var searchBar = page.getViewById("searchBar");
searchBar.on("propertyChange", function (args) {
var searchText = args.object.text;
if (searchText === "") {
// NOT SURE WHAT TO DO HERE.
} else {
peopleList.filter(function (element, index, array) {
// DOESN"T WORK PROPERLY
console.log("element: ", JSON.stringify(element));
return element.fullName == searchText;
});
console.log("Text types: ", searchText);
}
});
};
exports.showDetail = function(args) {
var person = peopleList.getItem(args.index);
var navigateEntry = {
moduleName: "views/people/people-detail",
context: { person: person },
animated: false
};
frames.topmost().navigate(navigateEntry);
};
PeopleListViewModel.js
var config = require("./config");
var fetchModule = require("fetch");
var ObservableArray = require("data/observable-array").ObservableArray;
function PeopleListViewModel(people) {
var viewModel = new ObservableArray(people);
viewModel.load = function (userKey) {
return fetchModule.fetch(config.baseUrl + "/api/people/all/" + userKey)
.then(function (response) {
return response.json();
})
.then(function (data) {
data.forEach(function (person) {
viewModel.push(person);
});
}, function (error) {
console.log("Error: ", error);
});
};
viewModel.empty = function () {
while (viewModel.length) {
viewModel.pop();
}
};
return viewModel;
}
function handleErrors(response) {
if (!response.ok) {
console.log("Error occurred");
}
}
module.exports = PeopleListViewModel;
Updated people-list
var frames = require("ui/frame");
var Observable = require("data/observable").Observable;
var ObservableArray = require("data/observable-array").ObservableArray;
var PeopleListViewModel = require("../../shared/people-viewModel");
var activityIndicatorModule = require("ui/activity-indicator");
var page;
var userkey;
var peopleList = new PeopleListViewModel([]);
var pageData = new Observable({ peopleList: peopleList });
var resultList = new ObservableArray([]);
exports.pageLoaded = function(args) {
page = args.object;
page.bindingContext = pageData;
userkey = userkey || page.navigationContext.userkey;
peopleList.load(userkey);
var searchBar = page.getViewById("searchBar");
searchBar.on("propertyChange", function (args) {
var searchText = args.object.text;
if (searchText === "") {
} else {
while (resultList.length > 0) {
resultList.pop();
}
peopleList.forEach(function (element) {
if (element.fullName === searchText) {
resultList.push(element);
}
});
}
});
};
I had the same issue. If you want to filter your data after every character has changed in search-bar you can try my solution.
Definitions
My playerList is your peopleList. This is the data from view-model.
resultList is an array where the data will be pushed.
var observableArrayModule = require("data/observable-array").ObservableArray;
var playerList = new PlayerListViewModel([]);
var resultList = new observableArrayModule([]);
var pageData = new observableModule.Observable({
resultList: resultList,
player: ""
});
Inside expors.loaded()
page = args.object;
searchBar = page.getViewById("search-bar");
page.bindingContext = pageData;
Load Initial Data - inside expors.loaded()
We are loading initial data when user navigates to the screen for the first time. We are also pushing the same data to resultList since we are using {{resultList}} in xml. You can add loadingIndicator while the list is populated.
playerList
.load()
.then(function() {
setTimeout(function() {
playerList.forEach(function (element) {
pageData.resultList.push(element);
});
}, 1000);
})
.catch(function(error) {
dialogsModule.alert({
message: "An error occurred while loading players.",
okButtonText: "OK"
});
});
Clear autofocus - inside expors.loaded()
This is to prevent keyboard from opening on initial screen navigation.
if (searchBar.ios) {
searchBar.ios.endEditing(true);
} else if (searchBar.android) {
searchBar.android.clearFocus();
}
Search data when character has changed - inside expors.loaded()
I am calling filter functionality. Lodash _.debounce function is used to delay looping through resultList array. Without it, the app would loop every time letter is typed. Now we are waiting for user to stop typing to start looping.
searchBar.on('propertyChange', _.debounce(searchList, 500));
searchList Function
This is the actual loop. You can change element.name for your needs.
function searchList(args) {
var searchText = args.object.text;
while(resultList.length > 0) {
resultList.pop();
}
playerList.forEach(function (element) {
if (element.name.toLowerCase().indexOf(searchText) >= 0) {
resultList.push(element);
}
});
}
Hide keyboard if search-bar is cleared - inside exports.loaded()
And finally we want to hide the keyboard if user clears the search-bar.
searchBar.on(searchBarModule.SearchBar.clearEvent, function (args) {
setTimeout(function() {
searchBar.dismissSoftInput();
}, 10);
});
PS
You probably solved your issue, but this could help someone else in the future.
Okay so your problem is a Javascript problem than a NativeScript problem. For the sake of this problem, think of observable arrays as just your ordinary arrays.
In your JS you're creating a new PeopleListViewModel which you're then attaching to the bindingContext via the pageData object. So far so good. Then you're calling the load method on the PeopleListViewModel (It returns a promise which you're not really doing anything with but for this specific problem it doesn't matter).
However, when text is inputed you're not really doing anything. This is your code:
peopleList.filter(function (element, index, array) {
// DOESN"T WORK PROPERLY
console.log("element: ", JSON.stringify(element));
return element.fullName == searchText;
});
peopleList is an instance of PeopleListViewModel which returns an ObservableArray. The ObservableArray does indeed have a method called filter (which works just like filter of a regular array. Check out the NativeScript documentation and Javascript documentation of filter).
What you need to understand here is that filter returns a new array with the filtered results. Doing peopleList.filter() will send that new array into empty space. You want to var yourNewFilteredArray = peopleList.filter(). But you don't really want to redefine the array bound to the binding context, you want to modify the content of it.
Here's an example of how you could do that:
/*
* Attach a new obsersable array to the binding context.
* you can prepopulate it with the data from the
* PeopleListViewModel if you want to
*/
var resultList = new ObservableArray([]);
var pageData = new Observable({ resultList: resultList });
/*
* Then on search/filter you want to modify this new
* array. Here I first remove every item in it and then
* push matching items to it.
*/
searchBar.on("propertyChange", function (args) {
var searchText = args.object.text;
// ...
while(resultList.length > 0) {
resultList.pop();
}
peopleList.forEach(function (element) {
if (element.fullName === searchText) {
resultList.push(element);
}
});
});

winJS ListView dynamic datasource edit issue

winJS ListView issue
I am working on a winJS application.I have listview.I need to add new data to an existing list view.How can i do that?
Normally the listview is bound with a WinJS.Binding.List, just add new items to that list and they'll appear inside listview.
Suggest use WinJS.Binding.List.createSorted() first and createGrouped on the sorted list. if your sort function can ensure that the newly inserted item comes ahead in sort order - it should appear first in the group.
_initializeListView: function initializeListView()
{
var data = [{ title: 'parle-ggg', brand: 'parle' }, { title: 'parle-gg', brand: 'parle' }, { title: 'parle-g', brand: 'parle' },
{ title: 'maggi-sauce', brand: 'maggi' }, { title: 'maggi-sauce-2', brand: 'maggi' }, { title: 'maggi-sauce-3', brand: 'maggi' }];
var list = new WinJS.Binding.List(data);
var sortedList = list.createSorted(function sorter(item1, item2)
{
var result;
if (item1.title < item2.title)
result = -1;
else if (item1.title == item2.title)
result = 0;
else
result = 1;
return result;
});
var groups = sortedList.createGrouped(
function groupKey(item)
{
return item.brand;
},
function groupData(item)
{
var result = { title: item.brand };
return result;
}
);
listView.winControl.itemDataSource = groups.dataSource;
listView.winControl.groupDataSource = groups.groups.dataSource;
this.sortedList = sortedList;
},
_oncmdclick: function oncmdclick(event) // this is event handler where you want to add new item
{
this.sortedList.push(newItem);
},
the above code snippet is tries to create a list sorted by title and grouped by brand. on inserting an item later in sortedList - inserted item is placed in the group properly. for example - adding an item by title 'parle-f' will place it first in the parle brand group whereas adding an item by title 'parle-h' will place it last in the parle brand group.
HTH.

How to find or trace child click in tableviewrow (Titanium Studio)

I am new to Titanium Studio. I'm working on table view. I've added some Image views and Labels in a tableviewrow. Can I add eventlistener to the each children in table view row. And I'm adding rows to the table inside a loop. Below is my code:
var tweetsTable = Ti.UI.createTableView({height:360, width: 306, top: 58, backgroundColor: '#FFFFFF',borderColor: '#C8C8C8',borderWidth:2, zIndex: -1});
var tweetsArray = [];
for(int i = 0; i < 5; i++)
{
var row = Ti.UI.createTableViewRow({contentHeight: 'auto', width: 320,top:0, selectionStyle : Titanium.UI.iPhone.TableViewCellSelectionStyle.NONE});
var my = Ti.UI.createView({ top:10,width:300,height:100 });
var accImage = Ti.UI.createImageView({Image: Ti.App.logoImage,width:50,height:50,left:10,top:5,borderRadius:4});
var addPlus = Ti.UI.createLabel({text:"+",color:"orange", font:{fontSize:18},borderWidth:0,bottom:5,right:20, width: 20, height: 20 });
var addMinus = Ti.UI.createLabel({text:"-",color:"orange", font:{fontSize:18},borderWidth:0,bottom:5,right:10, width: 20, height: 20 });
my.add(accImage);
my.add(addPlus);
my.add(addMinus);
row.add(my);
tweetsArray.push(row);
accImage.addEventListener('click', function(e){
alert(i);
}
addPlus.addEventListener('click', function(e){
alert(i);
}
addMinus.addEventListener('click', function(e){
alert(i);
}
}
I want to add event listener for accImage,addPlus,addMinus. But i unable to find click event of accImage,addPlus,addMinus separately. If i add event listener inside for loop it working, but the last row children only working. If i click first row addPlus, then the last row addPlus is working.
How can i add event listener dynamically for each children in each row.
Can any one please..
I found the solution. My code is below:
var tweetsTable = Ti.UI.createTableView({height:360, width: 306, top: 58, backgroundColor: '#FFFFFF',borderColor: '#C8C8C8',borderWidth:2, zIndex: -1});
var tweetsArray = [];
// response contains array of contents. The following loop will runs up to response length
for(int i = 0; i < response.length; i++)
{
var row = Ti.UI.createTableViewRow({contentHeight: 'auto', width: 320,top:0, selectionStyle : Titanium.UI.iPhone.TableViewCellSelectionStyle.NONE});
var my = Ti.UI.createView({ top:10,width:300,height:100 });
var accImage = Ti.UI.createImageView({Image: Ti.App.logoImage,width:50,height:50,left:10,top:5,borderRadius:4});
var addPlus = Ti.UI.createLabel({text:"+",color:"orange", font:{fontSize:18},borderWidth:0,bottom:5,right:20, width: 20, height: 20 });
var addMinus = Ti.UI.createLabel({text:"-",color:"orange", font:{fontSize:18},borderWidth:0,bottom:5,right:10, width: 20, height: 20 });
my.add(accImage);
my.add(addPlus);
my.add(addMinus);
row.add(my);
tweetsArray.push(row);
//find whether event from accImage
tweetsArray[i].children[0].addEventListener('click', function(e){
imageFunction(response[e.index]['name']);
});
//find whether event from addPlus
tweetsArray[i].children[1].addEventListener('click', function(e){
plusFunction(response[e.index]['name']);
});
//find whether event from addMinus
tweetsArray[i].children[2].addEventListener('click', function(e){
minusFunction(response[e.index]['name']);
});
}
I hope it will useful to some one.
Well, I believe your requirement is better suited using the example source code from Titanium Mobile's Kitchen Sink example (Table_view_layout2.js). You can get the source for this inside the Titanium Studio IDE, there is a Samples section on the lower left where you can import the code. In the code, navigate to Resources/iu/common/baseui/table_view_layout2.js to view or debug the example and see how it operates. Make sure you get an updated one, since it looks like they have updated this code since version 2.0.0 was released.
It has a single event listener for the table and queries the source of the click. The example shows an image, which is using a view rather than image view and several labels. The listener determines the item that was clicked and displays it on the screen. You can change that logic to do whatever it is you are trying to accomplish. Similar to your code, they build the table using a for loop, so you can draw some parallels to your code.
For the specific Tweet id, you can place that in your row variable.
var row = Ti.UI.createTableViewRow({
contentHeight: 'auto',
width: 320,
top:0,
selectionStyle : Titanium.UI.iPhone.TableViewCellSelectionStyle.NONE,
myTweetId: tweetId // <================= Add here
});
Then in your listener logic, you can query the e.rowData.myTweetid to find which tweet you need to modify.
Just to clarify, the listeners would reduce down to a single listener on the table's (tweetsTable) 'click' event and it would be defined outside of the loop logic you have.
I didn't really want to paste this in here, but this is the code in the file. You could have just looked it up in the free source code I mentioned as well as being able to run through it with the debugger.
function tv_layout2() {
var win = Titanium.UI.createWindow();
win.barColor = '#385292';
if (Ti.Platform.osname !== 'mobileweb') {
//
// CREATE SEARCH BAR
//
var search = Titanium.UI.createSearchBar({
barColor:'#385292',
showCancel:false
});
search.addEventListener('change', function(e)
{
e.value; // search string as user types
});
search.addEventListener('return', function(e)
{
search.blur();
});
search.addEventListener('cancel', function(e)
{
search.blur();
});
}
var tableView;
var data = [];
// create first row
var row = Ti.UI.createTableViewRow();
row.backgroundColor = '#576996';
row.selectedBackgroundColor = '#385292';
row.height = 40;
var clickLabel = Titanium.UI.createLabel({
text:'Click different parts of the row',
color:'#fff',
textAlign:'center',
font:{fontSize:14},
width:'auto',
height:'auto'
});
row.className = 'header';
row.add(clickLabel);
data.push(row);
// when you click the header, scroll to the bottom
row.addEventListener('click',function()
{
tableView.scrollToIndex(40,{animated:true,position:Ti.UI.iPhone.TableViewScrollPosition.TOP});
});
// create update row (used when the user clicks on the row)
function createUpdateRow(text)
{
var updateRow = Ti.UI.createTableViewRow();
updateRow.backgroundColor = '#13386c';
updateRow.selectedBackgroundColor = '#13386c';
// add custom property to identify this row
updateRow.isUpdateRow = true;
var updateRowText = Ti.UI.createLabel({
color:'#fff',
font:{fontSize:20, fontWeight:'bold'},
text:text,
width:'auto',
height:'auto'
});
updateRow.className = 'updated_row';
updateRow.add(updateRowText);
return updateRow;
}
// create a var to track the active row
var currentRow = null;
var currentRowIndex = null;
// create the rest of the rows
for (var c=1;c<50;c++)
{
var row = Ti.UI.createTableViewRow();
row.selectedBackgroundColor = '#fff';
row.height = 100;
row.className = 'datarow';
row.clickName = 'row';
var photo = Ti.UI.createView({
backgroundImage:'/images/custom_tableview/user.png',
top:5,
left:10,
width:50,
height:50,
clickName:'photo'
});
row.add(photo);
var user = Ti.UI.createLabel({
color:'#576996',
font:{fontSize:16,fontWeight:'bold', fontFamily:'Arial'},
left:70,
top:2,
height:30,
width:200,
clickName:'user',
text:'Fred Smith '+c
});
row.filter = user.text;
row.add(user);
var fontSize = 16;
if (Titanium.Platform.name == 'android') {
fontSize = 14;
}
var comment = Ti.UI.createLabel({
color:'#222',
font:{fontSize:fontSize,fontWeight:'normal', fontFamily:'Arial'},
left:70,
top:21,
height:50,
width:200,
clickName:'comment',
text:'Got some fresh fruit, conducted some business, took a nap'
});
row.add(comment);
var calendar = Ti.UI.createView({
backgroundImage:'/images/custom_tableview/eventsButton.png',
bottom:2,
left:70,
width:32,
clickName:'calendar',
height:32
});
row.add(calendar);
var button = Ti.UI.createView({
backgroundImage:'/images/custom_tableview/commentButton.png',
top:35,
right:5,
width:36,
clickName:'button',
height:34
});
row.add(button);
var date = Ti.UI.createLabel({
color:'#999',
font:{fontSize:13,fontWeight:'normal', fontFamily:'Arial'},
left:105,
bottom:5,
height:20,
width:100,
clickName:'date',
text:'posted on 3/11'
});
row.add(date);
data.push(row);
}
//
// create table view (
//
if (Ti.Platform.osname !== 'mobileweb') {
tableView = Titanium.UI.createTableView({
data:data,
search:search,
filterAttribute:'filter',
backgroundColor:'white'
});
} else {
tableView = Titanium.UI.createTableView({
data:data,
filterAttribute:'filter',
backgroundColor:'white'
});
}
tableView.addEventListener('click', function(e)
{
Ti.API.info('table view row clicked - source ' + e.source);
// use rowNum property on object to get row number
var rowNum = e.index;
var updateRow;
if (Ti.Platform.osname !== 'mobileweb') {
updateRow = createUpdateRow('You clicked on the '+e.source.clickName);
tableView.updateRow(rowNum,updateRow,{animationStyle:Titanium.UI.iPhone.RowAnimationStyle.LEFT});
} else {
updateRow = createUpdateRow('Row clicked');
tableView.updateRow(rowNum,updateRow);
}
});
win.add(tableView);
return win;
};
module.exports = tv_layout2;

window opens twice or more on single click in dynamic tableview - appcelerator

So i have a dynamic tableview.
when i click on one of the rows i got a new screen. It works, but on the top left the back button shows the title of the current window, so i have to click min 2 times on, to get back to the tableviews tab. Any idea why?
var win = Titanium.UI.currentWindow;
Titanium.include('strip_tags.js');
var tab = Titanium.UI.currentTab;
var tableView = Titanium.UI.createTableView({top:43,
separatorStyle: 'none',
backgroundColor:'transparent'});
win.add(tableView);
Ti.UI.currentWindow.addEventListener('focus', function() {
loadTweets();
});
function loadTweets()
{
var rowData = [];
var loader = Titanium.Network.createHTTPClient();
loader.open("GET","url", true);
loader.onload = function()
{
var tweets =JSON.parse(this.responseText);
for (var i = 0; i < tweets.length; i++)
{
var id = tweets[i].id;
var title = tweets[i].name; // The tweet message
var special=tweets[i].special;
if(special>0) {
var price=tweets[i].special;
var color2='#4C6B22';
} else {
var color2='#fff';
var price=tweets[i].price;
}
var thumb = tweets[i].thumb; // The profile image
title=title.replace('®', '');
title=title.replace('™', '');
var row = Titanium.UI.createTableViewRow({height:'auto',top:20 , backgroundImage:Ti.Filesystem.resourcesDirectory + '/images/row_bg.png', borderWidth:0, separatorStyle: 'none'});
var post_view = Titanium.UI.createView({
height:'auto',
layout:'vertical',
top:0,
right:5,
bottom:0,
left:5,
borderWidth:0,
height:49
});
var av_thumb = Titanium.UI.createImageView({
url:thumb, // the image for the image view
top:0,
left:0,
height:48,
width:48
});
post_view.add(av_thumb);
var av_title = Titanium.UI.createLabel({
text:title,
left:54,
width:210,
top:-30,
bottom:2,
height:16,
textAlign:'left',
color:'#fff',
font:{fontFamily:'Trebuchet MS',fontSize:14,fontWeight:'bold'}
});
post_view.add(av_title);
var av_desc = Titanium.UI.createLabel({
text:special,
left:270,
top:-20,
color:'#fff',
bottom:2,
height:'auto',
width:236,
textAlign:'left',
font:{fontSize:14}
});
post_view.add(av_desc);
row.add(post_view);
row.className = "item"+i;
row.thisTitle = title;
row.thisId = id;
rowData[i] = row;
}
var winCount = Titanium.UI.createLabel({
text:tweets.length+' blalba',
height:43,
top:0,
left:0,
width:320,
height:50,
textAlign:'center',
color:'#fff',
backgroundImage:Ti.Filesystem.resourcesDirectory + '/images/row_bg.png',
font:{fontFamily:'Trebuchet MS',fontSize:14,fontWeight:'bold'}
});
win.add(winCount);
tableView.setData(rowData);
tableView.addEventListener('click', function(e){
var w2 = Titanium.UI.createWindow({
title:e.rowData.thisTitle,
url:'cikk.js',
barColor:'#000',
backgroundImage:Ti.Filesystem.resourcesDirectory + '/images/winbg.png'
});
w2.stringProp1 = strip_tags(e.rowData.thisId);
tab.open(w2, {
animated:true
});
}
)};
loader.send();
}
my hunch is the that the eventListener focus is getting called twice and that is causing the tweets to get loaded twice which then cause the tableView eventListener to get loaded twice.
if you are going to use focus to add the eventListener, then I would suggest using blur to remove the eventListener.