Since Ok Alert is shown, you are in the good way and the callback function is called successfully.
The problem here is that calling removeAllChildren
method is not removing rows from your picker. the solution is to iterate over colums and delete rows like this :
Ti.App.addEventListener('db_update', function(){
alert("OK");
//get picker columns
var columns=$.picker.getColumns();
//Iterate over picker columns
for (var it=0,length=columns.length;i<length;it++){
//iterate over column rows
if(columns[it]){
var len = col.rowCount;
for(var index=0,collength=columns[it].length;index<collength;index++){
//remove rows[index] of columns[it]
columns[it].removeRow(columns[it].rows[index]);
}
}
}
});
By the way Applcelerator's folks said that using global events (Ti.App events) may cause problems in memory managements...
Keep in mind that app-level events are global, which means they remain in context the entire time your app is running (unless you remove them). This also means that any objects they reference will also remain in scope while your app runs. This could prevent those objects from being garbage collected.
Appcelerator Documentation.
Another method is to use global functions:
In your first view controller (where picker is defined):
Alloy.Globals.removeAllPickerChildren=function(){
//do what you want here
};
then in the seconde viewcontroller:
$.btnclick.addEventListener('click', function(){
if(Alloy.Globals.removeAllPickerChildren)
Alloy.Globals.removeAllPickerChildren();
});