Reputation: 597
I have developing the titanium tableview. here if i have select any row , need to pass the row values from one window to next window.
But From my code .,
Am getting the list of table rows successfully. the row data also passed.
But i have facing a problem ., First time am clicking one row means the null value is passed . After that come back the list view and click another row means the previous selected row id is passed to next window .why i have facing this issue ? what's problem here ? Please give me a solution .
I have using below code :
dataArray = [];
for(var i=0; i<json.length; i++){
var row = Ti.UI.createTableViewRow({
className: 'row',
objName: 'row',
folder_id:json[i].folder_id,
layout : 'horizontal',
touchEnabled: true,
width: "100%",
height: Ti.UI.SIZE,
});
row.add(Ti.UI.createLabel({
text: json[i].folder_id,
title: json[i].folder_id,
left: 10,
top: 5,
width: 0,
visible : false,
font: { fontSize: '18dp' },
color: '#040404',
wordWrap: true,
height: Ti.UI.SIZE,
ellipsize: true
}));
row.add(Ti.UI.createLabel({
text: json[i].folder_name,
title: json[i].folder_name,
left: 10,
top: 5,
width: 100,
font: { fontSize: '18dp' },
color: '#040404',
wordWrap: true,
height: Ti.UI.SIZE,
ellipsize: true
}));
dataArray.push(row);
};
$.FoldertableView.setData(dataArray);
$.FoldertableView.addEventListener('click', function(e){
Ti.API.info("folder_id"+ e.rowData.folder_id );
var managereditfolder =Alloy.createController('editfolder').getView();
Ti.App.Properties.setString("folder_id", e.rowData.folder_id);
managereditfolder.open();
});
editfolder.js
folder_id = Ti.App.Properties.getString("folder_id");
Ti.API.info("Edit Folder folder_id"+ folder_id );
here am getting the output like :
folder_id 14 [WARN] : Invalid value auto specified for property top [INFO] : Edit Folder folder_id null
folder_id 5 [WARN] : Invalid value auto specified for property top [INFO] : Edit Folder folder_id 14
Please check my code and give me a solutions
Upvotes: 0
Views: 643
Reputation: 1138
$.FoldertableView.addEventListener('click', function(e){
Ti.API.info("folder_id"+ e.rowData.folder_id );
var managereditfolder = Alloy.createController('editfolder').getView();
managereditfolder.folder_id = e.rowData.folder_id;
managereditfolder.open();
});
and in editfolder.js you can simply access it by
$.editFolderWin.folder_id
Upvotes: 0
Reputation: 1667
You do not need to save your data to Ti.App.Properties
to pass it to another view controller, you can rather do the following:
Pass data to the controller you create
var managereditfolder = Alloy.createController('editfolder', { folderId: e.rowData.folder_id } ).getView();
In editfolder.js you will receive the folder id by
// This holds all the Objects you pass along when
// creating the controller
var args = arguments[0] || {};
// Hence, your folderId is args.folderId
Ti.API.debug( args.folderId );
P.S.
Don't forget to always put a var
before any new variable you declare, otherwise you might get in trouble with the global scope!
Upvotes: 1